lib/Elastica/Query.php
public static function create($query)
    {
        switch (true) {
            case $query instanceof self:
                return $query;
            case $query instanceof AbstractQuery:
                return new self($query);
            case empty($query):
                return new self(new MatchAll());
            case \is_array($query):
                return new self($query);
            case \is_string($query):
                return new self(new QueryString($query));
            case $query instanceof AbstractSuggest:
                return new self(new Suggest($query));

            case $query instanceof Suggest:
                return new self($query);
        }

        throw new InvalidException('Unexpected argument to create a query for.');
    }
public static function create($query)
    {
        switch (true) {
            case $query instanceof self:
                return $query;
            case $query instanceof AbstractQuery:
                return new self($query);
            case empty($query):
                return new self(new MatchAll());
            case \is_array($query):
                return new self($query);
            case \is_string($query):
                return new self(new QueryString($query));
            case $query instanceof AbstractSuggest:
                return new self(new Suggest($query));

            case $query instanceof Suggest:
                return new self($query);
        }

        throw new InvalidException('Unexpected argument to create a query for.');
    }
public static function create ( $ query ) { switch ( true ) { case $ query instanceof self : return $ query ; case $ query instanceof AbstractQuery : return new self ( $ query ) ; case empty ( $ query ) : return new self ( new MatchAll ( ) ) ; case \ is_array ( $ query ) : return new self ( $ query ) ; case \ is_string ( $ query ) : return new self ( new QueryString ( $ query ) ) ; case $ query instanceof AbstractSuggest : return new self ( new Suggest ( $ query ) ) ; case $ query instanceof Suggest : return new self ( $ query ) ; } throw new InvalidException ( 'Unexpected argument to create a query for.' ) ; }
Transforms the argument to a query object.

For example, an empty argument will return a \Elastica\Query with a \Elastica\Query\MatchAll.

@param mixed $query

@throws InvalidException For an invalid argument

@return self
Transforms the argument to a query object .