Batch
in package
implements
BatchInterface
Default batch implementation used to convert queued items into smaller chunks of batches using a {@see BatchDivisorIterface} and transfers each batch using a {@see BatchTransferInterface}.
Any exception encountered during a flush operation will throw a BatchTransferException object containing the batch that failed. After an exception is encountered, you can flush the batch again to attempt to finish transferring any previously created batches or queued items.
Table of Contents
Interfaces
- BatchInterface
- Interface for efficiently transferring items in a queue using batches
Properties
- $dividedBatches : array<string|int, mixed>
- $divisionStrategy : BatchDivisorInterface
- $queue : SplQueue
- $transferStrategy : BatchTransferInterface
Methods
- __construct() : mixed
- add() : self
- Add an item to the queue
- flush() : array<string|int, mixed>
- Flush the batch and transfer the items
- isEmpty() : bool
- Check if the batch is empty and has further items to transfer
- createBatches() : mixed
- Create batches for any queued items
Properties
$dividedBatches
protected
array<string|int, mixed>
$dividedBatches
Divided batches to be transferred
$divisionStrategy
protected
BatchDivisorInterface
$divisionStrategy
$queue
protected
SplQueue
$queue
Queue of items in the queue
$transferStrategy
protected
BatchTransferInterface
$transferStrategy
Methods
__construct()
public
__construct(BatchTransferInterface $transferStrategy, BatchDivisorInterface $divisionStrategy) : mixed
Parameters
- $transferStrategy : BatchTransferInterface
-
Strategy used to transfer items
- $divisionStrategy : BatchDivisorInterface
-
Divisor used to create batches
add()
Add an item to the queue
public
add(mixed $item) : self
Parameters
- $item : mixed
-
Item to add
Return values
selfflush()
Flush the batch and transfer the items
public
flush() : array<string|int, mixed>
Return values
array<string|int, mixed> —Returns an array flushed items
isEmpty()
Check if the batch is empty and has further items to transfer
public
isEmpty() : bool
Return values
boolcreateBatches()
Create batches for any queued items
protected
createBatches() : mixed