/** * conveniant method to create new instances * @param string $collection * @return MongoObject */ public function newObject($collection) { /** @var MongoObject $obj */ $obj = $this->container->getInstanceOf($this->classMap->getClassForResult($collection, [])); $obj->setCollection($collection); return $obj; }
/** * Iterator::current * return current specific object * * @return MongoObject * @throws Exception */ public function current() { $documentData = $this->myResultCursor->current(); /** @var MongoObject $document */ $document = $this->container->getInstanceOf($this->classMapInterface->getClassForResult($this->collection, $documentData)); $document->setCollection($this->collection); $document->loadFromArray($documentData); return $document; }