private function makeIterator(Traversable $cursor) : Iterator
    {
        if ($this->hydrate) {
            $cursor = new HydratingIterator($cursor, $this->dm->getUnitOfWork(), $this->class, $this->unitOfWorkHints);
        }

        $cursor = new CachingIterator($cursor);

        if (! empty($this->primers)) {
            $referencePrimer = new ReferencePrimer($this->dm, $this->dm->getUnitOfWork());
            $cursor          = new PrimingIterator($cursor, $this->class, $referencePrimer, $this->primers, $this->unitOfWorkHints);
        }

        return $cursor;
    }
private function makeIterator(Traversable $cursor) : Iterator
    {
        if ($this->hydrate) {
            $cursor = new HydratingIterator($cursor, $this->dm->getUnitOfWork(), $this->class, $this->unitOfWorkHints);
        }

        $cursor = new CachingIterator($cursor);

        if (! empty($this->primers)) {
            $referencePrimer = new ReferencePrimer($this->dm, $this->dm->getUnitOfWork());
            $cursor          = new PrimingIterator($cursor, $this->class, $referencePrimer, $this->primers, $this->unitOfWorkHints);
        }

        return $cursor;
    }
private function makeIterator ( Traversable $ cursor ) : Iterator { if ( $ this -> hydrate ) { $ cursor = new HydratingIterator ( $ cursor , $ this -> dm -> getUnitOfWork ( ) , $ this -> class , $ this -> unitOfWorkHints ) ; } $ cursor = new CachingIterator ( $ cursor ) ; if ( ! empty ( $ this -> primers ) ) { $ referencePrimer = new ReferencePrimer ( $ this -> dm , $ this -> dm -> getUnitOfWork ( ) ) ; $ cursor = new PrimingIterator ( $ cursor , $ this -> class , $ referencePrimer , $ this -> primers , $ this -> unitOfWorkHints ) ; } return $ cursor ; }
Decorate the cursor with caching, hydration, and priming behavior.

Note: while this method could strictly take a MongoDB\Driver\Cursor, we
accept Traversable for testing purposes since Cursor cannot be mocked.
HydratingIterator and CachingIterator both expect a Traversable so this
should not have any adverse effects.
Decorate the cursor with caching hydration and priming behavior .