コード例 #1
0
ファイル: IterablesMatcher.php プロジェクト: phpspec/phpspec
 /**
  * @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;
 }
コード例 #2
0
ファイル: Changelog.php プロジェクト: nochso/writeme
 /**
  * @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();
 }
コード例 #3
0
ファイル: Iterator.php プロジェクト: sasezaki/Diggin_Scraper
 /**
  * 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);
 }
コード例 #4
0
 function current()
 {
     $value = parent::current();
     $fn = $this->callback;
     $fn($value);
     return $value;
 }
コード例 #5
0
 public function current()
 {
     $consumer = $this->consumer;
     $current = parent::current();
     $consumer($current);
     return $current;
 }
コード例 #6
0
ファイル: RangeIterator.php プロジェクト: malkusch/php-index
 public function valid()
 {
     if (!parent::valid()) {
         return false;
     }
     return $this->range->contains($this->current()->getKey());
 }
コード例 #7
0
ファイル: ColumnIterator.php プロジェクト: lox/pheasant
 public function current()
 {
     $row = parent::current();
     $keys = array_keys($row);
     $column = $this->_column ?: array_shift($keys);
     return $row[$column];
 }
コード例 #8
0
 public function rewind()
 {
     parent::rewind();
     if ($this->valid()) {
         $this->currentResult = $this->handleItem($this->current());
     }
 }
コード例 #9
0
ファイル: Transform.php プロジェクト: mikevanwinkle/cli
 public function current()
 {
     $value = parent::current();
     foreach ($this->transformers as $fn) {
         $value = $fn($value);
     }
     return $value;
 }
コード例 #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;
 }
コード例 #11
0
ファイル: Cursor.php プロジェクト: mootensai/yii2-mongodb
 /**
  * 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;
 }
コード例 #12
0
 public function next()
 {
     if ($this->isfirstrun) {
         $this->firstrun();
         $this->isfirstrun = FALSE;
     }
     parent::next();
 }
コード例 #13
0
ファイル: Tree.php プロジェクト: nosch/phpMyFAQ
 /**
  * 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;
 }
コード例 #14
0
 /**
  * @inheritDoc
  */
 public function current()
 {
     if (empty($this->_headers)) {
         $this->_headers = parent::current();
         parent::next();
     }
     return array_combine($this->_headers, parent::current());
 }
コード例 #15
0
ファイル: ChunkedIterator.php プロジェクト: jorjoh/Varden
 public function next()
 {
     $this->chunk = array();
     for ($i = 0; $i < $this->chunkSize && parent::valid(); $i++) {
         $this->chunk[] = parent::current();
         parent::next();
     }
 }
コード例 #16
0
ファイル: Transform.php プロジェクト: Jaace/wp-cli
 public function current()
 {
     $value = parent::current();
     foreach ($this->transformers as $fn) {
         $value = call_user_func($fn, $value);
     }
     return $value;
 }
コード例 #17
0
 public function Count($wherefunc = NULL)
 {
     if (!$wherefunc) {
         return count($this->lookup);
     } else {
         return parent::Count($wherefunc);
     }
 }
コード例 #18
0
ファイル: TakeIterator.php プロジェクト: alexeyshockov/colada
 public function rewind()
 {
     parent::rewind();
     $this->found = false;
     if (ComparisonHelper::isEquals($this->current(), $this->to)) {
         $this->found = true;
     }
 }
コード例 #19
0
ファイル: EntityIterator.php プロジェクト: mheydt/scalr
 /**
  * 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());
 }
コード例 #20
0
 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;
 }
コード例 #21
0
ファイル: EntryIterator.php プロジェクト: genkgo/camt
 /**
  * @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);
 }
コード例 #22
0
ファイル: ChunkIterator.php プロジェクト: arduanov/pipes
 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;
 }
コード例 #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;
 }
コード例 #24
0
ファイル: Cache.php プロジェクト: Nycto/Round-Eights
 /**
  * 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");
     }
 }
コード例 #25
0
 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));
 }
コード例 #26
0
ファイル: Peek.php プロジェクト: stubbles/stubbles-sequence
 /**
  * returns the current key
  *
  * @return  mixed
  */
 public function key()
 {
     $key = parent::key();
     if (null !== $this->keyConsumer) {
         $consumeKey = $this->keyConsumer;
         $consumeKey($key);
     }
     return $key;
 }
コード例 #27
0
ファイル: EntryIterator.php プロジェクト: vdbelt/camt
 /**
  * @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);
 }
コード例 #28
0
ファイル: MapIterator.class.php プロジェクト: evilgeny/bob
 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);
 }
コード例 #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));
     }
 }
コード例 #30
0
ファイル: Callback.php プロジェクト: rafeca/Pinq
 /**
  * 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);
     }
 }