/** * Actually returns a Traversable object with the DriverCursor within. * If it does not exists yet, create it using the $collection, $command and * $params given. * * @return Traversable */ protected function getCursor() : Traversable { if (!$this->cursor) { $params = $this->getConverter()->toMongoTypes($this->params); $driverCursor = $this->collection->{$this->command}(...$params); $this->cursor = new IteratorIterator($driverCursor); $this->cursor->rewind(); } return $this->cursor; }
/** * Rewind the Iterator to the first element * @link http://php.net/manual/en/iterator.rewind.php * @return void Any returned value is ignored. * @since 5.0.0 */ public function rewind() { $this->cursor->rewind(); }