diff options
Diffstat (limited to 'vendor/guzzle/guzzle/src/Guzzle/Batch/BatchSizeDivisor.php')
-rw-r--r-- | vendor/guzzle/guzzle/src/Guzzle/Batch/BatchSizeDivisor.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/src/Guzzle/Batch/BatchSizeDivisor.php b/vendor/guzzle/guzzle/src/Guzzle/Batch/BatchSizeDivisor.php new file mode 100644 index 0000000..67f90a5 --- /dev/null +++ b/vendor/guzzle/guzzle/src/Guzzle/Batch/BatchSizeDivisor.php @@ -0,0 +1,47 @@ +<?php + +namespace Guzzle\Batch; + +/** + * Divides batches into smaller batches under a certain size + */ +class BatchSizeDivisor implements BatchDivisorInterface +{ + /** @var int Size of each batch */ + protected $size; + + /** @param int $size Size of each batch */ + public function __construct($size) + { + $this->size = $size; + } + + /** + * Set the size of each batch + * + * @param int $size Size of each batch + * + * @return BatchSizeDivisor + */ + public function setSize($size) + { + $this->size = $size; + + return $this; + } + + /** + * Get the size of each batch + * + * @return int + */ + public function getSize() + { + return $this->size; + } + + public function createBatches(\SplQueue $queue) + { + return array_chunk(iterator_to_array($queue, false), $this->size); + } +} |