/**
  * {@inheritdoc}
  *
  * @return array|Document
  * @throws ODMException
  * @throws DefinitionException
  */
 public function current()
 {
     $fields = $this->cursor->current();
     if (empty($this->class)) {
         return $fields;
     }
     return $fields ? $this->odm->document($this->class, $fields) : null;
 }
 /**
  * Fetch or create instance of document based on specified offset.
  *
  * @param int $offset
  * @return DocumentEntity
  */
 private function getDocument($offset)
 {
     /**
      * @var array|Document $document
      */
     $document = $this->documents[$offset];
     if ($document instanceof CompositableInterface) {
         return $document;
     }
     //Trying to create using ODM
     return $this->documents[$offset] = $this->odm->document($this->class, $document, $this);
 }
 /**
  * {@inheritdoc}
  *
  * Accessor options include field type resolved by DocumentSchema.
  *
  * @throws ODMException
  * @throws DefinitionException
  */
 protected function createAccessor($accessor, $value)
 {
     $options = null;
     if (is_array($accessor)) {
         list($accessor, $options) = $accessor;
     }
     if ($accessor == ODM::CMP_ONE) {
         //Pointing to document instance
         $accessor = $this->odm->document($options, $value, $this);
     } else {
         //Additional options are supplied for CompositableInterface
         $accessor = new $accessor($value, $this, $this->odm, $options);
     }
     return $accessor;
 }