Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 2
0
 /**
  * @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();
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 6
0
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     return $this->range->contains($this->current()->getKey());
 }
Exemplo n.º 7
0
 public function current()
 {
     $row = parent::current();
     $keys = array_keys($row);
     $column = $this->_column ?: array_shift($keys);
     return $row[$column];
 }
Exemplo n.º 8
0
 public function rewind()
 {
     parent::rewind();
     if ($this->valid()) {
         $this->currentResult = $this->handleItem($this->current());
     }
 }
Exemplo n.º 9
0
 public function current()
 {
     $value = parent::current();
     foreach ($this->transformers as $fn) {
         $value = $fn($value);
     }
     return $value;
 }
Exemplo n.º 10
0
 /**
  * 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;
 }
Exemplo n.º 11
0
 /**
  * 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();
 }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
0
 /**
  * @inheritDoc
  */
 public function current()
 {
     if (empty($this->_headers)) {
         $this->_headers = parent::current();
         parent::next();
     }
     return array_combine($this->_headers, parent::current());
 }
Exemplo n.º 15
0
 public function next()
 {
     $this->chunk = array();
     for ($i = 0; $i < $this->chunkSize && parent::valid(); $i++) {
         $this->chunk[] = parent::current();
         parent::next();
     }
 }
Exemplo n.º 16
0
 public function current()
 {
     $value = parent::current();
     foreach ($this->transformers as $fn) {
         $value = call_user_func($fn, $value);
     }
     return $value;
 }
Exemplo n.º 17
0
 public function Count($wherefunc = NULL)
 {
     if (!$wherefunc) {
         return count($this->lookup);
     } else {
         return parent::Count($wherefunc);
     }
 }
Exemplo n.º 18
0
 public function rewind()
 {
     parent::rewind();
     $this->found = false;
     if (ComparisonHelper::isEquals($this->current(), $this->to)) {
         $this->found = true;
     }
 }
Exemplo n.º 19
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 current()
 {
     //Here we get the actual record to transform!
     $row = parent::current();
     if ($this->formatted) {
         $row = $this->format($row, $this->model);
     }
     return $row;
 }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
0
 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;
 }
Exemplo n.º 23
0
 public function current()
 {
     $out = parent::current();
     if ($this->callback_fn) {
         $modified_out = call_user_func($this->callback_fn, $out);
         return $modified_out;
     }
     return $out;
 }
Exemplo n.º 24
0
 /**
  * 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));
 }
Exemplo n.º 26
0
 /**
  * returns the current key
  *
  * @return  mixed
  */
 public function key()
 {
     $key = parent::key();
     if (null !== $this->keyConsumer) {
         $consumeKey = $this->keyConsumer;
         $consumeKey($key);
     }
     return $key;
 }
Exemplo n.º 27
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);
 }
Exemplo n.º 28
0
 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);
 }
Exemplo n.º 29
0
 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));
     }
 }
Exemplo n.º 30
0
 /**
  * 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);
     }
 }