Elastica\QueryBuilder\Version::supports PHP Method

supports() public method

returns true if $name is supported, false otherwise.
public supports ( string $name, $type ) : boolean
$name string
$type
return boolean
    public function supports($name, $type)
    {
        switch ($type) {
            case DSL::TYPE_QUERY:
                return in_array($name, $this->queries);
            case DSL::TYPE_AGGREGATION:
                return in_array($name, $this->aggregations);
            case DSL::TYPE_SUGGEST:
                return in_array($name, $this->suggesters);
        }
        // disables version check in Facade for custom DSL objects
        return true;
    }

Usage Example

Example #1
0
 /**
  * Executes DSL methods
  *
  * @throws QueryBuilderException
  *
  * @param  string $name
  * @param  array  $arguments
  * @return mixed
  */
 public function __call($name, array $arguments)
 {
     // defined check
     if (false === method_exists($this->_dsl, $name)) {
         throw new QueryBuilderException('undefined ' . $this->_dsl->getType() . ' "' . $name . '"');
     }
     // version support check
     if (false === $this->_version->supports($name, $this->_dsl->getType())) {
         $reflection = new \ReflectionClass($this->_version);
         throw new QueryBuilderException($this->_dsl->getType() . ' "' . $name . '" in ' . $reflection->getShortName() . ' not supported');
     }
     return call_user_func_array(array($this->_dsl, $name), $arguments);
 }