/usr/share/php/Guzzle/Iterator/ChunkedIterator.php is in php-guzzle 3.7.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | <?php
namespace Guzzle\Iterator;
/**
* Pulls out chunks from an inner iterator and yields the chunks as arrays
*/
class ChunkedIterator extends \IteratorIterator
{
/** @var int Size of each chunk */
protected $chunkSize;
/** @var array Current chunk */
protected $chunk;
/**
* @param \Traversable $iterator Traversable iterator
* @param int $chunkSize Size to make each chunk
*/
public function __construct(\Traversable $iterator, $chunkSize)
{
parent::__construct($iterator);
$this->chunkSize = $chunkSize;
}
public function rewind()
{
$this->next();
}
public function next()
{
$this->chunk = array();
$inner = $this->getInnerIterator();
for ($i = 0; $i < $this->chunkSize && $inner->valid(); $i++) {
$this->chunk[] = $inner->current();
$inner->next();
}
}
public function current()
{
return $this->chunk;
}
public function valid()
{
return !empty($this->chunk);
}
}
|