Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * 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;
 }
Example #4
0
 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;
 }
Example #7
0
 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);
 }
Example #8
0
 public function __construct(Iterator $iterator, $selector)
 {
     parent::__construct($iterator);
     if ($selector === null) {
         throw new InvalidArgumentException("Selector must not be null.");
     }
     $this->selector = $selector;
 }
Example #9
0
 /**
  * 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;
 }
Example #10
0
 public function __construct(IIterator $outerIterator, IIterator $innerIterator)
 {
     parent::__construct($outerIterator);
     self::__constructIterator();
     $this->outerIterator =& $this->iterator;
     $this->innerIterator = $innerIterator;
     $this->innerValuesIterator = new EmptyIterator();
 }
Example #11
0
 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());
     }
 }
Example #12
0
 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;
 }
Example #13
0
 /**
  * @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;
 }
Example #14
0
 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;
 }
Example #15
0
 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);
 }
Example #16
0
 /**
  * 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);
 }
Example #17
0
 /**
  * @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);
 }
Example #18
0
 /**
  * @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);
 }
Example #19
0
 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));
 }
Example #20
0
 /**
  * @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;
 }
Example #21
0
 /**
  * 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));
 }
Example #23
0
 /**
  *	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);
 }
Example #24
0
 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;
     }
 }
Example #25
0
 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);
 }
Example #26
0
 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);
 }
Example #29
0
 /**
  * ( 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);
     }
 }