Alcaeus\MongoDbAdapter\AbstractCursor::storeIteratorState PHP Method

storeIteratorState() protected method

This is necessary because hasNext() might advance the iterator but we still need to be able to return the current object.
protected storeIteratorState ( )
    protected function storeIteratorState()
    {
        if (!$this->startedIterating) {
            $this->current = null;
            $this->key = null;
            $this->valid = false;
            return null;
        }
        $this->current = $this->ensureIterator()->current();
        $this->key = $this->ensureIterator()->key();
        $this->valid = $this->ensureIterator()->valid();
        if ($this->current !== null) {
            $this->current = TypeConverter::toLegacy($this->current);
        }
        return $this->current;
    }