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($iterable, $offset, $length = INF, $preserveKeys = false) { parent::__construct(IterUtil::asTraversable($iterable)); $this->offset = $offset; $this->length = $length; $this->preserveKeys = $preserveKeys; }
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 __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; }
/** * @test * @expectedException InvalidArgumentException */ public function testAsTraversableWithNonTraversableAsArgument() { IterUtil::asTraversable(1); }
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($innerIterator) { parent::__construct(IterUtil::asTraversable($innerIterator)); }
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($iterator, PDO $pdo, $timeout = 1.0) { parent::__construct(IterUtil::asTraversable($iterator)); $this->timeout = $timeout; $this->pdo = $pdo; }