original_string: protected function referencesOne(string $entity, string $field, bool $cacheable = true)
      {
          $referenced_id = $this->$field;
  
          if (is_array($referenced_id) && isset($referenced_id[0])) {
              $referenced_id = $referenced_id[0];
          }
  
          $entityInstance = Ioc::make($entity);
  
          if ($entityInstance instanceof Schema) {
              $dataMapper = Ioc::make(DataMapper::class);
              $dataMapper->setSchema($entityInstance);
  
              return $dataMapper->first(['_id' => $referenced_id], [], $cacheable);
          }
  
          return $entityInstance::first(['_id' => $referenced_id], [], $cacheable);
      }
code: protected function referencesOne(string $entity, string $field, bool $cacheable = true)
      {
          $referenced_id = $this->$field;
  
          if (is_array($referenced_id) && isset($referenced_id[0])) {
              $referenced_id = $referenced_id[0];
          }
  
          $entityInstance = Ioc::make($entity);
  
          if ($entityInstance instanceof Schema) {
              $dataMapper = Ioc::make(DataMapper::class);
              $dataMapper->setSchema($entityInstance);
  
              return $dataMapper->first(['_id' => $referenced_id], [], $cacheable);
          }
  
          return $entityInstance::first(['_id' => $referenced_id], [], $cacheable);
      }
code_tokens: protected function referencesOne ( string $ entity , string $ field , bool $ cacheable = true ) { $ referenced_id = $ this -> $ field ; if ( is_array ( $ referenced_id ) && isset ( $ referenced_id [ 0 ] ) ) { $ referenced_id = $ referenced_id [ 0 ] ; } $ entityInstance = Ioc :: make ( $ entity ) ; if ( $ entityInstance instanceof Schema ) { $ dataMapper = Ioc :: make ( DataMapper :: class ) ; $ dataMapper -> setSchema ( $ entityInstance ) ; return $ dataMapper -> first ( [ '_id' => $ referenced_id ] , [ ] , $ cacheable ) ; } return $ entityInstance :: first ( [ '_id' => $ referenced_id ] , [ ] , $ cacheable ) ; }
docstring: Returns the referenced documents as objects.
  
  @param string $entity    class of the entity or of the schema of the entity
  @param string $field     the field where the _id is stored
  @param bool   $cacheable retrieves a CacheableCursor instead
  
  @return mixed
docstring_tokens: Returns the referenced documents as objects .