NOTE: For Version 3 of the AWS SDK for PHP, please see the V3 User Guide and V3 API Reference.

# Class BatchBuilder

Builder used to create custom batch objects

Namespace: Guzzle\Batch
Located at Guzzle/Batch/BatchBuilder.php

## Methods summary

- `public static` `factory ( )`

  Create a new instance of the BatchBuilder

- `public` `autoFlushAt ( mixed $threshold )`

  Automatically flush the batch when the size of the queue reaches a certain threshold. Adds `Guzzle\Batch\FlushingBatch`.

- `public` `keepHistory ( )`

  Maintain a history of all items that have been transferred using the batch. Adds `Guzzle\Batch\HistoryBatch`.

- `public` `bufferExceptions ( )`

  Buffer exceptions thrown during transfer so that you can transfer as much as possible, and after a transfer completes, inspect each exception that was thrown. Enables the `Guzzle\Batch\ExceptionBufferingBatch` decorator.

- `public` `notify ( mixed $callable )`

  Notify a callable each time a batch flush completes. Enables the `Guzzle\Batch\NotifyingBatch` decorator.

- `public` `transferRequests ( int $batchSize = 50 )`

  Configures the batch to transfer batches of requests. Associates a \Guzzle\Http\BatchRequestTransfer object as both the transfer and divisor strategy.

- `public` `transferCommands ( int $batchSize = 50 )`

  Configures the batch to transfer batches commands. Associates as \Guzzle\Service\Command\BatchCommandTransfer as both the transfer and divisor strategy.

- `public` `createBatchesWith ( Guzzle\Batch\BatchDivisorInterface $divisorStrategy )`

  Specify the strategy used to divide the queue into an array of batches

- `public` `transferWith ( Guzzle\Batch\BatchTransferInterface $transferStrategy )`

  Specify the strategy used to transport the items when flush is called

- `public` `build ( )`

  Create and return the instantiated batch

## Methods detail

# `public static `Guzzle\Batch\BatchBuilder``
`factory( )`

Create a new instance of the BatchBuilder

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`autoFlushAt( mixed $threshold )`

Automatically flush the batch when the size of the queue reaches a certain threshold. Adds `Guzzle\Batch\FlushingBatch`.

#### Parameters

$threshold
  `mixed`
  $threshold Number of items to allow in the queue before a flush

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`keepHistory( )`

Maintain a history of all items that have been transferred using the batch. Adds `Guzzle\Batch\HistoryBatch`.

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`bufferExceptions( )`

Buffer exceptions thrown during transfer so that you can transfer as much as possible, and after a transfer completes, inspect each exception that was thrown. Enables the `Guzzle\Batch\ExceptionBufferingBatch` decorator.

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`notify( mixed $callable )`

Notify a callable each time a batch flush completes. Enables the `Guzzle\Batch\NotifyingBatch` decorator.

#### Parameters

$callable
  `mixed`
  $callable Callable function to notify

#### Returns

``Guzzle\Batch\BatchBuilder``

#### Throws

``Guzzle\Common\Exception\InvalidArgumentException``
if the argument is not callable
# `public `Guzzle\Batch\BatchBuilder``
`transferRequests( integer $batchSize = 50 )`

Configures the batch to transfer batches of requests. Associates a \Guzzle\Http\BatchRequestTransfer object as both the transfer and divisor strategy.

#### Parameters

$batchSize
  `integer`
  $batchSize Batch size for each batch of requests

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`transferCommands( integer $batchSize = 50 )`

Configures the batch to transfer batches commands. Associates as \Guzzle\Service\Command\BatchCommandTransfer as both the transfer and divisor strategy.

#### Parameters

$batchSize
  `integer`
  $batchSize Batch size for each batch of commands

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`createBatchesWith( `Guzzle\Batch\BatchDivisorInterface` $divisorStrategy )`

Specify the strategy used to divide the queue into an array of batches

#### Parameters

$divisorStrategy
  ``Guzzle\Batch\BatchDivisorInterface``
  $divisorStrategy Strategy used to divide a batch queue into batches

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchBuilder``
`transferWith( `Guzzle\Batch\BatchTransferInterface` $transferStrategy )`

Specify the strategy used to transport the items when flush is called

#### Parameters

$transferStrategy
  ``Guzzle\Batch\BatchTransferInterface``
  $transferStrategy How items are transferred

#### Returns

``Guzzle\Batch\BatchBuilder``
# `public `Guzzle\Batch\BatchInterface``
`build( )`

Create and return the instantiated batch

#### Returns

``Guzzle\Batch\BatchInterface``

#### Throws

``Guzzle\Common\Exception\RuntimeException``
if no transfer strategy has been specified

### Magic methods summary

## Properties summary

`protected boolean` | $autoFlush | # Whether or not the batch should automatically flush
`protected boolean` | $history | # Whether or not to maintain a batch history
`protected boolean` | $exceptionBuffering | # Whether or not to buffer exceptions encountered in transfer
`protected mixed` | $afterFlush | # Callable to invoke each time a flush completes
`protected `Guzzle\Batch\BatchTransferInterface`` | $transferStrategy | # Object used to transfer items in the queue
`protected `Guzzle\Batch\BatchDivisorInterface`` | $divisorStrategy | # Object used to divide the queue into batches
`protected static array` | $mapping | # of Mapped transfer strategies by handle name