public function __construct($innerIterator) { parent::__construct(IterUtil::asIterator($innerIterator)); $this->lookAheads = new Queue(); $this->skipAutoRewind = false; $this->skipNextNormalRewind = false; }
public function __construct($innerIterator, $maxHistorySize = 1) { parent::__construct(IterUtil::asIterator($innerIterator)); $this->history = new Queue(); $this->maxHistorySize = $maxHistorySize; $this->hasStoredCurrent = false; }
public function __construct($iterable, $offset, $length = INF, $preserveKeys = false) { parent::__construct(IterUtil::asTraversable($iterable)); $this->offset = $offset; $this->length = $length; $this->preserveKeys = $preserveKeys; }
public function __construct($iterable, $options = array()) { parent::__construct(IterUtil::asTraversable($iterable)); $this->iterationCount = 0; $defaultOptions = array('autoPrint' => false, 'printTo' => 'php://stdout', 'printInterval' => DateInterval::createFromDateString('5 seconds')); $this->options = array_merge($defaultOptions, $options); if (!$this->options['printInterval'] instanceof DateInterval) { throw new InvalidArgumentException('printInterval must be an instance of DateInterval'); } $unknownOptions = array_diff(array_keys($options), array_keys($defaultOptions)); if (count($unknownOptions) != 0) { throw new InvalidArgumentException('Unknown options specified: ' . implode(', ', $unknownOptions)); } if ($this->options['autoPrint']) { $file = $this->options['printTo']; if (is_resource($file)) { $this->printToFileHandle = $file; $this->closePrintToFileHandleOnDestruct = false; } else { if (is_string($file)) { $this->printToFileHandle = @fopen($file, 'a'); if ($this->printToFileHandle === false) { throw new InvalidArgumentException("Could not open file with path: '{$file}'"); } $this->closePrintToFileHandleOnDestruct = true; } else { throw new InvalidArgumentException('You must provide either a stream or filename as printTo argument, you provided a ' . gettype($file)); } } } }
public function __construct($iterator, $callback) { parent::__construct(IterUtil::asIterator($iterator)); if (!is_callable($callback)) { throw new InvalidArgumentException('No valid callback provided'); } $this->callback = $callback; }
public function __construct($iterator, $callback) { parent::__construct(IterUtil::asTraversable($iterator)); if (!is_callable($callback)) { throw new InvalidArgumentException('The callback must be callable'); } $this->callback = $callback; }
public function retrieveNextCsvRow() { $nextLine = IterUtil::getCurrentAndAdvance($this->lines, array('default' => false)); if ($nextLine === false) { return false; } $rows = str_getcsv($nextLine, $this->options['delimiter'], $this->options['enclosure'], $this->options['escape']); return count($rows) == 0 ? false : $rows; }
public function __construct(array $iterators) { if (count($iterators) == 0) { throw new InvalidArgumentException('Cannot construct a ZipIterator from an empty array of iterators'); } $this->iterators = array(); foreach ($iterators as $iterator) { $this->iterators[] = IterUtil::asIterator($iterator); } }
/** @test */ public function testCustomComparator() { $input = new GroupByIterator(array((object) array('name' => 'jos', 'age' => 3), (object) array('name' => 'mieke', 'age' => 3), (object) array('name' => 'tom', 'age' => 4), (object) array('name' => 'lotte', 'age' => 5), (object) array('name' => 'jaak', 'age' => 5)), function ($v) { return $v->age; }); $inputArray = IterUtil::recursive_iterator_to_array($input, false); $this->assertEquals('jos', $inputArray[0][0]->name); $this->assertEquals('mieke', $inputArray[0][1]->name); $this->assertEquals('tom', $inputArray[1][0]->name); $this->assertEquals('lotte', $inputArray[2][0]->name); $this->assertEquals('jaak', $inputArray[2][1]->name); }
public function setNextValidSubIterator() { while ($this->iterator->valid()) { $this->currentSubIterator = IterUtil::asIterator($this->iterator->current()); $this->currentSubIterator->rewind(); if ($this->currentSubIterator->valid()) { return; } $this->iterator->next(); } $this->currentSubIterator = new EmptyIterator(); }
public function __construct($innerIterable, $comparator = null) { parent::__construct(IterUtil::asIterator($innerIterable)); if (null === $comparator) { $comparator = function ($value) { return $value; }; } if (!is_callable($comparator)) { throw new InvalidArgumentException('Comparator must be a callable'); } $this->comparator = $comparator; $this->groupIndex = 0; }
public function __construct($innerItererator, $mapCallback, $batchSize = 100, $type = 0) { if (!is_callable($mapCallback)) { throw new InvalidArgumentException('The callback must be callable'); } if (($type & self::DONT_ALLOW_MERGE) == 0 && $innerItererator instanceof self && $batchSize == $innerItererator->getBatchSize() && $type == $innerItererator->getType()) { parent::__construct(IterUtil::asTraversable($innerItererator->getInnerIterator())); $this->mapCallbacks = array_merge($innerItererator->getMapCallbacks(), array($mapCallback)); } else { parent::__construct(IterUtil::asTraversable($innerItererator)); $this->mapCallbacks = array($mapCallback); } $this->type = $type; $this->batchSize = $batchSize; }
public function __construct($startNodes, $getChildrenCallback) { parent::__construct(IterUtil::asIterator($startNodes)); $this->getChildrenCallback = $getChildrenCallback; }
public function __construct($innerIterator, $options = array()) { parent::__construct(IterUtil::asTraversable($innerIterator)); $this->forkingEnabled = array_key_exists('forkingEnabled', $options) ? $options['forkingEnabled'] : self::ENABLED; $this->maxChildren = array_key_exists('maxChildren', $options) ? $options['maxChildren'] : 8; }
public function __construct($innerIterator) { $this->innerIterator = IterUtil::asIterator($innerIterator); }
public function __construct($innerIterator) { parent::__construct(IterUtil::asTraversable($innerIterator)); }
/** * @test * @expectedException InvalidArgumentException **/ public function testAllShouldThrowExceptionIfSuppliedWithInvalidCallable() { IterUtil::all(array(), 66); }
public function __construct($iterable, $dir, $lockNameMapper = null) { parent::__construct(IterUtil::asTraversable($iterable)); $this->dir = $dir; $this->lockNameMapper = $lockNameMapper; }
public function __construct($iterable, $filter) { parent::__construct(IterUtil::asTraversable($iterable)); $this->filter = $filter; }
public function __construct($iterator, PDO $pdo, $batchSize = 100) { $this->batchSize = $batchSize; $this->pdo = $pdo; parent::__construct(IterUtil::asTraversable($iterator)); }
public function __construct($iterator, PDO $pdo, $timeout = 1.0) { parent::__construct(IterUtil::asTraversable($iterator)); $this->timeout = $timeout; $this->pdo = $pdo; }
public function unshiftAll($collection) { IterUtil::assertIsCollection($collection); foreach ($collection as $element) { $this->unshift($element); } return $this; }
public function __construct($iterator) { parent::__construct(IterUtil::asIterator($iterator)); }
public function __construct($innerIterator) { parent::__construct(IterUtil::asIterator($innerIterator)); $this->currentUpToDate = false; $this->validUpToDate = false; }