Documentation

BatchClosureDivisor
in package
implements BatchDivisorInterface

Divides batches using a callable

Interfaces, Classes and Traits

BatchDivisorInterface
Interface used for dividing a queue of items into an array of batches

Table of Contents

$callable  : callable
$context  : mixed
__construct()  : mixed
createBatches()  : array<string|int, mixed>|Traversable
Divide a queue of items into an array batches

Properties

Methods

__construct()

public __construct(callable $callable[, mixed $context = null ]) : mixed
Parameters
$callable : callable

Method used to divide the batches. The method must accept an \SplQueue and return an array of arrays containing the divided items.

$context : mixed = null

Optional context to pass to the batch divisor

Tags
throws
InvalidArgumentException

if the callable is not callable

Return values
mixed

createBatches()

Divide a queue of items into an array batches

public createBatches(SplQueue $queue) : array<string|int, mixed>|Traversable
Parameters
$queue : SplQueue

Queue of items to divide into batches. Items are removed as they are iterated.

Return values
array<string|int, mixed>|Traversable

Returns an array or Traversable object that contains arrays of items to transfer

Search results