/** * 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(); } }
public function current(){ if ($this->innerHasItems === true){ return $this->innerIterator->current(); } else { return $this->defaultValue; } }
/** * {@inheritdoc} */ public function current() { if (!$this->iterableResult) { $this->rewind(); } return $this->iterableResult->current(); }
private function getCurrentIterator() { if (null === $this->currentIterator) { $this->currentIterator = $this->mainIterator->current(); } return $this->currentIterator; }
/** * @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); } }); }
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; }
public function current() { if (!$this->usingCache) { $this->array[$this->position] = $this->innerIterator->current(); } return $this->array[$this->position]; }
/** * @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())); }
/** * 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); } }
private function memo() { if (!$this->it->valid()) { return; } array_push($this->cache, array($this->it->key(), $this->it->current())); $this->cacheSize++; }
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); } }
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); } }
public function fetch($fetchMode = null) { if (!$this->currentIterator) { $this->currentIterator = $this->getIterator(); } $data = $this->currentIterator->current(); $this->currentIterator->next(); return $data; }
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; }
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; }
public function valid() { if (!parent::valid()) { if ($this->source->valid()) { $this->append($this->transform($this->source->current())); } } return parent::valid(); }
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); }
public function rewind() { if ($this->continue) { $this->continue = false; return; } $this->iterator->rewind(); $this->stack->push($this->iterator->current()); }
/** * @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; }
/** * @return string */ public function dir_readdir() { if ($this->iterator->valid()) { $result = $this->iterator->current(); $this->iterator->next(); return $result; } else { return false; } }
/** * {@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; }
private function nextSatisfied() { while ($this->it->valid()) { if ($this->predicate->predicate($this->it->current(), $this->it->key())) { break; } else { $this->it->next(); } } }
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(); } }
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); } }
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; } } }
/** * (PHP 5 >= 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.'); } }
/** * @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; }
/** * 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; }
/** * 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']); }
/** * 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; } } }