original_string: protected function entityReferenceSearch($value, $entity) {
      if (!is_array($value) && !($value instanceof Traversable)) {
        return false;
      }
      if (!isset($entity)) {
        throw new Exceptions\InvalidParametersException();
      }
      // Get the GUID, if the passed $entity is an object.
      if (is_array($entity)) {
        foreach ($entity as &$curEntity) {
          if (is_object($curEntity)) {
            $curEntity = $curEntity->guid;
          }
        }
        unset($curEntity);
      } elseif (is_object($entity)) {
        $entity = [$entity->guid];
      } else {
        $entity = [(int) $entity];
      }
      if (isset($value[0]) && $value[0] === 'nymph_entity_reference') {
        return in_array($value[1], $entity);
      } else {
        // Search through multidimensional arrays looking for the reference.
        foreach ($value as $curValue) {
          if ($this->entityReferenceSearch($curValue, $entity)) {
            return true;
          }
        }
      }
      return false;
    }
code: protected function entityReferenceSearch($value, $entity) {
      if (!is_array($value) && !($value instanceof Traversable)) {
        return false;
      }
      if (!isset($entity)) {
        throw new Exceptions\InvalidParametersException();
      }
      // Get the GUID, if the passed $entity is an object.
      if (is_array($entity)) {
        foreach ($entity as &$curEntity) {
          if (is_object($curEntity)) {
            $curEntity = $curEntity->guid;
          }
        }
        unset($curEntity);
      } elseif (is_object($entity)) {
        $entity = [$entity->guid];
      } else {
        $entity = [(int) $entity];
      }
      if (isset($value[0]) && $value[0] === 'nymph_entity_reference') {
        return in_array($value[1], $entity);
      } else {
        // Search through multidimensional arrays looking for the reference.
        foreach ($value as $curValue) {
          if ($this->entityReferenceSearch($curValue, $entity)) {
            return true;
          }
        }
      }
      return false;
    }
code_tokens: protected function entityReferenceSearch ( $ value , $ entity ) { if ( ! is_array ( $ value ) && ! ( $ value instanceof Traversable ) ) { return false ; } if ( ! isset ( $ entity ) ) { throw new Exceptions \ InvalidParametersException ( ) ; } // Get the GUID, if the passed $entity is an object. if ( is_array ( $ entity ) ) { foreach ( $ entity as & $ curEntity ) { if ( is_object ( $ curEntity ) ) { $ curEntity = $ curEntity -> guid ; } } unset ( $ curEntity ) ; } elseif ( is_object ( $ entity ) ) { $ entity = [ $ entity -> guid ] ; } else { $ entity = [ ( int ) $ entity ] ; } if ( isset ( $ value [ 0 ] ) && $ value [ 0 ] === 'nymph_entity_reference' ) { return in_array ( $ value [ 1 ] , $ entity ) ; } else { // Search through multidimensional arrays looking for the reference. foreach ( $ value as $ curValue ) { if ( $ this -> entityReferenceSearch ( $ curValue , $ entity ) ) { return true ; } } } return false ; }
docstring: Search through a value for an entity reference.
  
  @param mixed $value Any value to search.
  @param array|Entity|int $entity An entity, GUID, or array of either to
  search for.
  @return bool True if the reference is found, false otherwise.
  @access protected
docstring_tokens: Search through a value for an entity reference .