/** * Ensures that the inner iterator is both Traversable and Countable * * {@inheritdoc} * * @throws InvalidArgumentException */ public function __construct(\Traversable $iterator) { if (!$iterator instanceof \Countable) { throw new InvalidArgumentException('The inner iterator for an ItemIterator must be Countable.'); } parent::__construct($iterator); }
/** * constructor * * @param Diggin_Scraper_Evaluator_Abstract $callback */ public function __construct(\Diggin\Scraper\Evaluator\AbstractEvaluator $callback) { if ($filters = $callback->getProcess()->getFilters()) { $callback = $this->_apply($callback, $filters); } return parent::__construct($callback); }
public function __construct(FileInterface $file, FileSpec $spec, RecordSpecRecognizerInterface $recognizer, ValueFormatterInterface $formatter) { parent::__construct($file); $this->spec = $spec; $this->recognizer = $recognizer; $this->formatter = $formatter; }
public function __construct($iterator = null) { if (is_array($iterator)) { $iterator = new ArrayIterator($iterator); } parent::__construct($iterator); }
/** * @inheritDoc */ public function __construct($path, $separator = ',') { $file = new SplFileObject($path); $file->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY); $file->setCsvControl($separator); parent::__construct($file); }
/** * * @param array $data * @param \MUtil_Model_ModelAbstract $model * @param boolean $formatted * @return \Gems_FormattedData */ public function __construct($data, \MUtil_Model_ModelAbstract $model, $formatted = true) { $this->data = parent::__construct(new \ArrayObject($data)); $this->model = $model; $this->setFormatted($formatted); return $this; }
public function __construct($iterator, $reducer) { if (!is_callable($reducer)) { throw new Exception('must pass valid reducer callback to this iterator'); } $this->reducer = $reducer; parent::__construct($iterator); }
public function __construct(Iterator $iterator, $selector) { parent::__construct($iterator); if ($selector === null) { throw new InvalidArgumentException("Selector must not be null."); } $this->selector = $selector; }
/** * Constructor * * @param PMF_Category $parent Parent PMF_Category object * * @return void */ public function __construct(PMF_Category_Tree_DataProvider_Interface $dataProvider, PMF_Category $parent = NULL) { $parentId = $parent ? (int) $parent->getId() : 0; $resultset = $dataProvider->getData($parentId); parent::__construct($resultset); $this->parent = $parent; $this->dataProvider = $dataProvider; }
public function __construct(IIterator $outerIterator, IIterator $innerIterator) { parent::__construct($outerIterator); self::__constructIterator(); $this->outerIterator =& $this->iterator; $this->innerIterator = $innerIterator; $this->innerValuesIterator = new EmptyIterator(); }
public function __construct(Traversable $iterator, $classNameModel) { parent::__construct($iterator); $this->classNameModel = $classNameModel; if (!is_subclass_of($classNameModel, Internals\Model::className()) && !in_array(Internals\Model::className(), class_parents($classNameModel))) { throw new ObjectException("{$classNameModel} must be subclass of " . Internals\Model::className()); } }
public function __construct(\Traversable $iterator, $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException(sprintf('Callback should be callable, "%s" given.', gettype($callback))); } parent::__construct($iterator); $this->callback = $callback; }
/** * @param \Traversable $iterator Traversable iterator * @param array|\Closure $callback Callback used for iterating * * @throws InvalidArgumentException if the callback if not callable */ public function __construct(\Traversable $iterator, $callback) { parent::__construct($iterator); if (!is_callable($callback)) { throw new InvalidArgumentException('The callback must be callable'); } $this->callback = $callback; }
public function __construct(\Traversable $iterator, $callback) { if (!is_callable($callback)) { throw new \InvalidArgumentException("Provided callback should be callable. Got " . gettype($callback)); } parent::__construct($iterator); $this->callback = $callback; }
function __construct(\Iterator $iterator, $flags = CachingIterator::CALL_TOSTRING) { $flags = $this->validateFlags($flags); if ($flags & self::FULL_CACHE) { $this->fullCacheIterator = new ArrayIterator(); } $this->flags = $flags; parent::__construct($iterator); }
/** * Construct * * @param \Traversable $traversable * @param integer $windowSize */ public function __construct(\Traversable $traversable, $windowSize) { // A window of size 0 or less is not allowed if ($windowSize <= 0) { throw new \OutOfBoundsException('Window size must be greater than zero'); } $this->windowSize = $windowSize; parent::__construct($traversable); }
/** * @param Message $message */ public function __construct(DTO\Message $message) { $appendIterator = new AppendIterator(); $records = $message->getRecords(); foreach ($records as $record) { $appendIterator->append(new ArrayIterator($record->getEntries())); } parent::__construct($appendIterator); }
/** * @param Message $message */ public function __construct(Message $message) { $appendIterator = new AppendIterator(); $statements = $message->getStatements(); foreach ($statements as $statement) { $appendIterator->append(new ArrayIterator($statement->getEntries())); } parent::__construct($appendIterator); }
public function __construct($iterator, $keyselect, $elementselect = NULL, $comparer = NULL) { $this->getkey = $keyselect; $this->getelement = $elementselect; $this->ismatch = $comparer; $this->buildlookup($iterator); //build our lookup array and pass to our parent. parent::__construct(new \ArrayIterator($this->lookup)); }
/** * @param \Traversable $iterator Traversable iterator * @param int $chunkSize Size to make each chunk * @throws \InvalidArgumentException */ public function __construct(\Traversable $iterator, $chunkSize) { $chunkSize = (int) $chunkSize; if ($chunkSize < 0) { throw new \InvalidArgumentException("The chunk size must be equal or greater than zero; {$chunkSize} given"); } parent::__construct($iterator); $this->chunkSize = $chunkSize; }
/** * Constructor * * @param string $entityClass The name of the class of the Entity in the collection * @param \ADORecordSet_mysqli $recordSet Result record set */ public function __construct($entityClass, $recordSet) { $this->entityClass = $entityClass; if (!$recordSet instanceof \ADORecordSet_mysqli) { throw new \InvalidArgumentException(sprintf("Argument must be instance of ADORecordSet class")); } $this->recordSet = $recordSet; parent::__construct($recordSet->getIterator()); }
public function __construct($path) { if (!file_exists($path) || !is_readable($path)) { throw new InvalidSentencesResourceException(); } $sentences = preg_split('/\\n/u', trim(file_get_contents($path))); $this->count = count($sentences); return parent::__construct(new ArrayIterator($sentences)); }
/** * Create map iterator. * * @param iterator Traversable iterator (object or array) * @param callback callback Callback for apply to every item * @param args list Optional extra args to callback. * first argument to callback ALWAYS is current item, * second argument to callback ALWAYS is current key * other arguments can be specified via "args". * @return */ public function __construct($iterator, $callback, $args = array()) { if (!is_callable($callback)) { throw new RM_Base_Exception_BadUsage("Second argument must be valid callback"); } parent::__construct(is_array($iterator) ? new ArrayIterator($iterator) : $iterator); $this->_callback = $callback; $this->_args = (array) $args; array_unshift($this->_args, NULL, NULL); }
public function __construct(\Traversable $iterator, array $columns, array $targets, GeneratorInterface $generator, UserManagerInterface $userManager) { parent::__construct($iterator); $this->columns = $columns; $this->generator = $generator; $this->userManager = $userManager; $this->targets = []; foreach ($targets as $target) { $this->targets[$target->getId()] = $target; } }
public function __construct($items) { if (is_array($items)) { $items = new \ArrayIterator($items); } if (!$items instanceof \Traversable) { $msg = 'Only an array or \\Traversable is allowed for Collection'; throw new \InvalidArgumentException($msg); } parent::__construct($items); }
function __construct($cacheId, $keyIterator, Backend $backend) { if (is_array($keyIterator)) { $keyIterator = new \ArrayIterator($keyIterator); } if (!$keyIterator instanceof \Iterator) { throw new \InvalidArgumentException(); } parent::__construct($keyIterator); $this->cacheId = $cacheId; $this->backend = $backend; }
/** * __construct * * @param array $items * @param array $fields */ public function __construct($items = array(), $fields = array(), $settings = array()) { if (is_array($items)) { $items = new ArrayIterator($items); } if (!$settings && is_array($fields) && isset($fields['fields'])) { $settings = $fields; } else { $settings['fields'] = (array) $fields; } $this->_settings = $settings + $this->_settings; parent::__construct($items); }
public function __construct(\Traversable $iterator) { /* * Prevent to trigger deprecation notice when already using the * InheritDataAwareIterator class that extends this deprecated one. * The {@link Symfony\Component\Form\Util\InheritDataAwareIterator::__construct} method * forces this argument to false. */ if (__CLASS__ === get_class($this)) { trigger_error('The ' . __CLASS__ . ' class is deprecated since version 2.3 and will be removed in 3.0. Use the Symfony\\Component\\Form\\Util\\InheritDataAwareIterator class instead.', E_USER_DEPRECATED); } parent::__construct($iterator); }
/** * ( excerpt from http://docs.hhvm.com/manual/en/limititerator.construct.php ) * * Constructs a new LimitIterator from an iterator with a given starting * offset and maximum count. * * @iterator mixed The Iterator to limit. * @offset mixed Optional offset of the limit. * @count mixed Optional count of the limit. * * @return mixed The new LimitIterator. */ public function __construct($iterator, $offset = 0, $count = -1) { if ($offset < 0) { throw new OutOfRangeException("Parameter offset must be >= 0"); } else { if ($count < -1) { throw new OutOfRangeException("Parameter count must either be -1 or " . "a value greater than or equal 0"); } } parent::__construct($iterator); $this->offset = $offset; $this->count = $count; }
/** * constructor * * @param \Traversable $iterator iterator to map values of * @param callable $valueMapper optional callable which maps the values * @param callable $keyMapper optional callable which maps the keys * @throws \InvalidArgumentException in case both $valueMapper and $keyMapper are null */ public function __construct(\Traversable $iterator, callable $valueMapper = null, callable $keyMapper = null) { if (null === $valueMapper && null === $keyMapper) { throw new \InvalidArgumentException('Passed null for both valueMapper and keyMapper, but at ' . 'least one of both must not be null'); } parent::__construct($iterator); if (null !== $valueMapper) { $this->valueMapper = ensureCallable($valueMapper); $this->description[] = 'values mapped by ' . describeCallable($valueMapper); } if (null !== $keyMapper) { $this->keyMapper = ensureCallable($keyMapper); $this->description[] = 'keys mapped by ' . describeCallable($keyMapper); } }