private function hydrateEntity($document)
    {
        $class = $this->entityClass;
        $reflectionClass = new \ReflectionClass(AbstractDocument::class);
        $entity = new $class();

        if (!($entity instanceof AbstractDocument)) {
            throw new \Exception(sprintf('"%s" is not a subclass of "%s"', $this->entityClass, AbstractDocument::class));
        }

        $documentProperty = $reflectionClass->getProperty('document');
        $documentProperty->setAccessible(true);
        $documentProperty->setValue($entity, $document);

        return $entity;
    }
private function hydrateEntity($document)
    {
        $class = $this->entityClass;
        $reflectionClass = new \ReflectionClass(AbstractDocument::class);
        $entity = new $class();

        if (!($entity instanceof AbstractDocument)) {
            throw new \Exception(sprintf('"%s" is not a subclass of "%s"', $this->entityClass, AbstractDocument::class));
        }

        $documentProperty = $reflectionClass->getProperty('document');
        $documentProperty->setAccessible(true);
        $documentProperty->setValue($entity, $document);

        return $entity;
    }
private function hydrateEntity ( $ document ) { $ class = $ this -> entityClass ; $ reflectionClass = new \ ReflectionClass ( AbstractDocument :: class ) ; $ entity = new $ class ( ) ; if ( ! ( $ entity instanceof AbstractDocument ) ) { throw new \ Exception ( sprintf ( '"%s" is not a subclass of "%s"' , $ this -> entityClass , AbstractDocument :: class ) ) ; } $ documentProperty = $ reflectionClass -> getProperty ( 'document' ) ; $ documentProperty -> setAccessible ( true ) ; $ documentProperty -> setValue ( $ entity , $ document ) ; return $ entity ; }
Hydrates a document entity with a mongo document

@param mixed $document

@return AbstractDocument

@throws \Exception
Hydrates a document entity with a mongo document