/** * @param array|\Traversable $iterable * * @return \Iterator */ private function createIteratorFromIterable($iterable) { if (is_array($iterable)) { return new \ArrayIterator($iterable); } $iterator = new \IteratorIterator($iterable); $iterator->rewind(); return $iterator; }
/** * @param \nochso\WriteMe\Document $document * * @return \SplFileInfo */ private function findChangelog(Document $document) { $changelogName = $this->options->getValue('changelog.file'); $searchDepth = $this->options->getValue('changelog.search-depth'); $folder = dirname($document->getFilepath()); $files = new \IteratorIterator(Finder::findFiles($changelogName)->from($folder)->limitDepth($searchDepth)); $files->next(); if (!$files->valid()) { throw new \RuntimeException(sprintf("Unable to find changelog '%s' in folder '%s'", $changelogName, $folder)); } return $files->current(); }
/** * 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); }
function current() { $value = parent::current(); $fn = $this->callback; $fn($value); return $value; }
public function current() { $consumer = $this->consumer; $current = parent::current(); $consumer($current); return $current; }
public function valid() { if (!parent::valid()) { return false; } return $this->range->contains($this->current()->getKey()); }
public function current() { $row = parent::current(); $keys = array_keys($row); $column = $this->_column ?: array_shift($keys); return $row[$column]; }
public function rewind() { parent::rewind(); if ($this->valid()) { $this->currentResult = $this->handleItem($this->current()); } }
public function current() { $value = parent::current(); foreach ($this->transformers as $fn) { $value = $fn($value); } return $value; }
/** * for each configured field, if it's in the results, translate it * * @return array **/ public function current() { $value = parent::current(); foreach ($this->_settings['fields'] as $field) { $this->_update($value, $field); } return $value; }
/** * Return the current element * This method is required by the interface [[\Iterator]]. * @return mixed current row */ public function current() { $value = parent::current(); if (!isset($value['file'])) { $value['file'] = $this->collection->createDownload(array_intersect_key($value, ['_id' => true, 'filename' => true, 'length' => true, 'chunkSize' => true])); } return $value; }
public function next() { if ($this->isfirstrun) { $this->firstrun(); $this->isfirstrun = FALSE; } parent::next(); }
/** * 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; }
/** * @inheritDoc */ public function current() { if (empty($this->_headers)) { $this->_headers = parent::current(); parent::next(); } return array_combine($this->_headers, parent::current()); }
public function next() { $this->chunk = array(); for ($i = 0; $i < $this->chunkSize && parent::valid(); $i++) { $this->chunk[] = parent::current(); parent::next(); } }
public function current() { $value = parent::current(); foreach ($this->transformers as $fn) { $value = call_user_func($fn, $value); } return $value; }
public function Count($wherefunc = NULL) { if (!$wherefunc) { return count($this->lookup); } else { return parent::Count($wherefunc); } }
public function rewind() { parent::rewind(); $this->found = false; if (ComparisonHelper::isEquals($this->current(), $this->to)) { $this->found = true; } }
/** * 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 current() { //Here we get the actual record to transform! $row = parent::current(); if ($this->formatted) { $row = $this->format($row, $this->model); } return $row; }
/** * @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); }
public function next() { $this->chunk = array(); for ($i = 0; $i < $this->size && parent::valid(); ++$i) { $this->chunk[] = parent::current(); parent::next(); } $this->chunk ? $this->key++ : null; }
public function current() { $out = parent::current(); if ($this->callback_fn) { $modified_out = call_user_func($this->callback_fn, $out); return $modified_out; } return $out; }
/** * Restarts the iterator * * @return NULL */ public function rewind() { if (!$this->rewound) { $this->rewound = TRUE; return parent::rewind(); } else { throw new PHPUnit_Framework_ExpectationFailedException("Iterator has already been rewound"); } }
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)); }
/** * returns the current key * * @return mixed */ public function key() { $key = parent::key(); if (null !== $this->keyConsumer) { $consumeKey = $this->keyConsumer; $consumeKey($key); } return $key; }
/** * @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 current() { if (!$this->valid()) { return NULL; } $this->_args[0] = parent::current(); $this->_args[1] = parent::key(); return call_user_func_array($this->_callback, $this->_args); }
public function current() { $val = parent::current(); if (!$this->resultselector) { return $val; } else { //project result return call_user_func_array($this->resultselector, array($this->aparent, $val)); } }
/** * Filters each item in the iteration to become the result of a callback * function. * * @return mixed */ public function current() { $cb = $this->callback; $itm = parent::current(); if ($cb instanceof \Closure) { return $cb($itm); } else { return call_user_func($cb, $itm); } }