original_string: public function references($document)
      {
          if ($this->currentField) {
              $mapping = $this->class->getFieldMapping($this->currentField);
              $dbRef = $this->dm->createDBRef($document, $mapping);
  
              if (isset($mapping['simple']) && $mapping['simple']) {
                  $this->query[$mapping['name']] = $dbRef;
              } else {
                  $keys = array('ref' => true, 'id' => true, 'db' => true);
  
                  if (isset($mapping['targetDocument'])) {
                      unset($keys['ref'], $keys['db']);
                  }
  
                  foreach ($keys as $key => $value) {
                      $this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key];
                  }
              }
          } else {
              $dbRef = $this->dm->createDBRef($document);
              $this->query = $dbRef;
          }
  
          return $this;
      }
code: public function references($document)
      {
          if ($this->currentField) {
              $mapping = $this->class->getFieldMapping($this->currentField);
              $dbRef = $this->dm->createDBRef($document, $mapping);
  
              if (isset($mapping['simple']) && $mapping['simple']) {
                  $this->query[$mapping['name']] = $dbRef;
              } else {
                  $keys = array('ref' => true, 'id' => true, 'db' => true);
  
                  if (isset($mapping['targetDocument'])) {
                      unset($keys['ref'], $keys['db']);
                  }
  
                  foreach ($keys as $key => $value) {
                      $this->query[$this->currentField . '.$' . $key] = $dbRef['$' . $key];
                  }
              }
          } else {
              $dbRef = $this->dm->createDBRef($document);
              $this->query = $dbRef;
          }
  
          return $this;
      }
code_tokens: public function references ( $ document ) { if ( $ this -> currentField ) { $ mapping = $ this -> class -> getFieldMapping ( $ this -> currentField ) ; $ dbRef = $ this -> dm -> createDBRef ( $ document , $ mapping ) ; if ( isset ( $ mapping [ 'simple' ] ) && $ mapping [ 'simple' ] ) { $ this -> query [ $ mapping [ 'name' ] ] = $ dbRef ; } else { $ keys = array ( 'ref' => true , 'id' => true , 'db' => true ) ; if ( isset ( $ mapping [ 'targetDocument' ] ) ) { unset ( $ keys [ 'ref' ] , $ keys [ 'db' ] ) ; } foreach ( $ keys as $ key => $ value ) { $ this -> query [ $ this -> currentField . '.$' . $ key ] = $ dbRef [ '$' . $ key ] ; } } } else { $ dbRef = $ this -> dm -> createDBRef ( $ document ) ; $ this -> query = $ dbRef ; } return $ this ; }
docstring: Checks that the value of the current field is a reference to the supplied document.
docstring_tokens: Checks that the value of the current field is a reference to the supplied document .