コード例 #1
0
 /**
  * Lazily append the next iterator to the chain
  */
 private function lazyAppend()
 {
     if (!parent::valid() and $this->iterators->valid()) {
         $this->append($this->iterators->current());
         $this->iterators->next();
     }
 }
コード例 #2
0
	public function current(){
		if ($this->innerHasItems === true){
			return $this->innerIterator->current();
		} else {
			return $this->defaultValue;
		}
	}
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     if (!$this->iterableResult) {
         $this->rewind();
     }
     return $this->iterableResult->current();
 }
コード例 #4
0
 private function getCurrentIterator()
 {
     if (null === $this->currentIterator) {
         $this->currentIterator = $this->mainIterator->current();
     }
     return $this->currentIterator;
 }
コード例 #5
0
ファイル: IteratorObservable.php プロジェクト: voryx/Rx.PHP
 /**
  * @param ObserverInterface $observer
  * @param SchedulerInterface|null $scheduler
  * @return \Rx\Disposable\CompositeDisposable|\Rx\DisposableInterface
  */
 public function subscribe(ObserverInterface $observer, SchedulerInterface $scheduler = null)
 {
     $scheduler = $scheduler ?: new ImmediateScheduler();
     $key = 0;
     return $scheduler->scheduleRecursive(function ($reschedule) use(&$observer, &$key) {
         try {
             //HHVM requires you to call next() before current()
             if (defined('HHVM_VERSION')) {
                 $this->items->next();
                 $key = $this->items->key();
             }
             if (null === $key) {
                 $observer->onCompleted();
                 return;
             }
             $current = $this->items->current();
             $observer->onNext($current);
             if (!defined('HHVM_VERSION')) {
                 $this->items->next();
                 $key = $this->items->key();
             }
             $reschedule();
         } catch (\Exception $e) {
             $observer->onError($e);
         }
     });
 }
コード例 #6
0
 public function valid()
 {
     get_next:
     // Return true if this function has already been called for iteration.
     if ($this->currentRequest) {
         return true;
     }
     // Return false if we are at the end of the provided commands iterator.
     if (!$this->commands->valid()) {
         return false;
     }
     $command = $this->commands->current();
     if (!$command instanceof CommandInterface) {
         throw new \RuntimeException('All commands provided to the ' . __CLASS__ . ' must implement GuzzleHttp\\Command\\CommandInterface.' . ' Encountered a ' . Core::describeType($command) . ' value.');
     }
     $command->setFuture('lazy');
     $this->attachListeners($command, $this->eventListeners);
     // Prevent transfer exceptions from throwing.
     $command->getEmitter()->on('process', function (ProcessEvent $e) {
         if ($e->getException()) {
             $e->setResult(null);
         }
     }, RequestEvents::LATE);
     $builder = $this->requestBuilder;
     $result = $builder($command);
     // Skip commands that were intercepted with a result.
     if (isset($result['result'])) {
         $this->commands->next();
         goto get_next;
     }
     $this->currentRequest = $result['request'];
     return true;
 }
コード例 #7
0
 public function current()
 {
     if (!$this->usingCache) {
         $this->array[$this->position] = $this->innerIterator->current();
     }
     return $this->array[$this->position];
 }
コード例 #8
0
ファイル: MappedIterator.php プロジェクト: mangowi/mediawiki
 /**
  * @return Mixed|null Returns null if out of range
  */
 public function current()
 {
     if (!$this->baseIterator->valid()) {
         return null;
         // out of range
     }
     return call_user_func_array($this->vCallback, array($this->baseIterator->current()));
 }
コード例 #9
0
ファイル: RecursiveFileIterator.php プロジェクト: brick/brick
 /**
  * Returns the current element.
  *
  * @return \SplFileInfo
  *
  * @throws FileSystemException If called after the last element has been returned.
  */
 public function current()
 {
     try {
         return $this->iterator->current();
     } catch (\RuntimeException $e) {
         throw FileSystemException::wrap($e);
     }
 }
コード例 #10
0
ファイル: MemoizeIterator.php プロジェクト: gunjiro/ginq
 private function memo()
 {
     if (!$this->it->valid()) {
         return;
     }
     array_push($this->cache, array($this->it->key(), $this->it->current()));
     $this->cacheSize++;
 }
コード例 #11
0
ファイル: EachIterator.php プロジェクト: gunjiro/ginq
 private function fetch()
 {
     if ($this->it->valid()) {
         $this->v = $this->it->current();
         $this->k = $this->it->key();
         $fn = $this->fn;
         $fn($this->v, $this->k);
     }
 }
コード例 #12
0
ファイル: SelectIterator.php プロジェクト: gunjiro/ginq
 private function fetch()
 {
     if ($this->it->valid()) {
         $v = $this->it->current();
         $k = $this->it->key();
         $this->v = $this->valueSelector->select($v, $k);
         $this->k = $this->keySelector->select($v, $k);
     }
 }
コード例 #13
0
 public function fetch($fetchMode = null)
 {
     if (!$this->currentIterator) {
         $this->currentIterator = $this->getIterator();
     }
     $data = $this->currentIterator->current();
     $this->currentIterator->next();
     return $data;
 }
コード例 #14
0
 public function current()
 {
     if ($this->projectionNeeded) {
         $projection = $this->projection;
         $this->current = $projection($this->innerIterator->current(), $this->innerIterator->key(), $this->innerIterator);
         $this->projectionNeeded = false;
     }
     return $this->current;
 }
コード例 #15
0
 public function current()
 {
     $current = $this->iterator->current();
     $fileCrate = new \HQ\ErrorMonitorinq\FileCrate();
     $fileCrate->name = $current["Key"];
     $fileCrate->size = $current["Size"];
     $fileCrate->lastModified = new \DateTime($current["LastModified"]);
     return $fileCrate;
 }
コード例 #16
0
 public function valid()
 {
     if (!parent::valid()) {
         if ($this->source->valid()) {
             $this->append($this->transform($this->source->current()));
         }
     }
     return parent::valid();
 }
コード例 #17
0
 public function current()
 {
     $request = $this->source->current();
     if (!$request instanceof puzzle_message_RequestInterface) {
         throw new RuntimeException('All must implement puzzle_message_RequestInterface');
     }
     $this->attachListeners($request, $this->eventListeners);
     return new puzzle_adapter_Transaction($this->client, $request);
 }
コード例 #18
0
ファイル: Iterator.php プロジェクト: edde-framework/edde
 public function rewind()
 {
     if ($this->continue) {
         $this->continue = false;
         return;
     }
     $this->iterator->rewind();
     $this->stack->push($this->iterator->current());
 }
コード例 #19
0
 /**
  * @param $limit
  * @return Resource[]
  */
 public function collect($limit = -1)
 {
     $resources = array();
     while ($limit && $this->iterator->valid()) {
         $resources[] = $this->iterator->current();
         $this->iterator->next();
         $limit--;
     }
     return $resources;
 }
コード例 #20
0
 /**
  * @return string
  */
 public function dir_readdir()
 {
     if ($this->iterator->valid()) {
         $result = $this->iterator->current();
         $this->iterator->next();
         return $result;
     } else {
         return false;
     }
 }
コード例 #21
0
ファイル: Set.php プロジェクト: th3n3rd/cartesian-product
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     $neighbourCurrent = $this->neighbour->current();
     $current = parent::current();
     if (!$this->neighbour instanceof Set) {
         $neighbourCurrent = array($neighbourCurrent);
     }
     array_unshift($neighbourCurrent, $current);
     return $neighbourCurrent;
 }
コード例 #22
0
ファイル: WhereIterator.php プロジェクト: gunjiro/ginq
 private function nextSatisfied()
 {
     while ($this->it->valid()) {
         if ($this->predicate->predicate($this->it->current(), $this->it->key())) {
             break;
         } else {
             $this->it->next();
         }
     }
 }
コード例 #23
0
ファイル: BufferIterator.php プロジェクト: gunjiro/ginq
 private function fetch()
 {
     $this->buffer = array();
     for ($i = 0; $i < $this->chunkSize; $i++) {
         if (!$this->it->valid()) {
             return;
         }
         array_push($this->buffer, $this->it->current());
         $this->it->next();
     }
 }
コード例 #24
0
 function current()
 {
     $values = $this->iterator->current();
     if ($this->perColumn) {
         foreach ($this->filters as $key => $filter) {
             $values[$key] = filter($values[$key], $filter);
         }
         return $values;
     } else {
         return filter($values, $this->filters);
     }
 }
コード例 #25
0
ファイル: DropWhileIterator.php プロジェクト: gunjiro/ginq
 public function rewind()
 {
     $this->i = 0;
     $this->it->rewind();
     while ($this->it->valid()) {
         if ($this->predicate->predicate($this->it->current(), $this->it->key())) {
             $this->it->next();
         } else {
             break;
         }
     }
 }
コード例 #26
0
ファイル: RequestIterator.php プロジェクト: piv915/guzzle
 /**
  * (PHP 5 &gt;= 5.0.0)<br/>
  * Return the current element
  * @link http://php.net/manual/en/iterator.current.php
  * @return mixed Can return any type.
  */
 public function current()
 {
     // TODO: Implement current() method.
     $rfn = $this->iterable->current();
     if ($rfn instanceof RequestInterface) {
         return $this->client->sendAsync($rfn, $this->opts);
     } elseif (is_callable($rfn)) {
         return $rfn($this->opts);
     } else {
         throw new \InvalidArgumentException('Each value yielded by ' . 'the iterator must be a Psr7\\Http\\Message\\RequestInterface ' . 'or a callable that returns a promise that fulfills ' . 'with a Psr7\\Message\\Http\\ResponseInterface object.');
     }
 }
コード例 #27
0
 /**
  * @inheritdoc
  */
 public function current()
 {
     $current = $this->delegatorReader->current();
     if (!$current) {
         $this->iterator->next();
         if (!$this->iterator->valid()) {
             return false;
         }
         $resource = $this->convertResource($this->resource, $this->iterator->current());
         $this->delegatorReader->open($resource);
         return $this->current();
     }
     return $current;
 }
コード例 #28
0
 /**
  * Filters the iterator values.
  *
  * @return bool true if the value should be kept, false otherwise
  */
 public function accept()
 {
     /** @var Directory|File $handler */
     $handler = $this->iterator->current();
     if ($this->isRecursive && isset($this->excludedDirs[$handler->getFilename()]) && $handler->isDir()) {
         return false;
     }
     if ($this->excludedPattern) {
         $path = $handler->isDir() ? $handler->getPath() : $handler->getDirname();
         $path = str_replace('\\', '/', $path);
         return !preg_match($this->excludedPattern, $path);
     }
     return true;
 }
コード例 #29
0
ファイル: Collection.php プロジェクト: jfsimon/datagrid
 /**
  * Returns next entity.
  *
  * @return Entity|null
  */
 public function next()
 {
     if (null !== $this->peek) {
         $entity = $this->peek;
         $this->peek = null;
         return $entity;
     }
     $item = $this->data->current();
     if (null === $item) {
         return null;
     }
     $this->data->next();
     return new Entity($item, $this->accessor, $this->options['mapping'], $this->options['id_path']);
 }
コード例 #30
0
ファイル: Cache.php プロジェクト: Nycto/Round-Eights
 /**
  * Internally increments the iterator and saves the value
  *
  * @return Boolean Returns whether the iterator returned a valid value
  */
 private function storeNext()
 {
     if (!isset($this->iterator)) {
         return FALSE;
     } else {
         if ($this->iterator->valid()) {
             $this->cache[$this->internalOffset] = array($this->iterator->key(), $this->iterator->current());
             return TRUE;
         } else {
             unset($this->iterator);
             return FALSE;
         }
     }
 }