@param string $query

@return UriInterface

@throws \InvalidArgumentException
974813
public function withQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new \InvalidArgumentException('Query string must be a string');
        }
        $query = (string) $query;
        if (strpos($query, '?') === 0) {
            $query = substr($query, 1);
        }
        $query = $this->filterQueryAndFragment($query);

        $new = clone $this;
        $new->query = $query;

        return $new;
    }
194122
public function setQuery($query)
    {
        if ($query instanceof Query) {
            $this->query = $query;
        } elseif (is_string($query)) {
            $this->query = Query::fromString($query);
        } elseif (is_array($query)) {
            $this->query = new Query($query);
        } else {
            throw new \InvalidArgumentException('Query must be a '
                . 'QueryInterface, array, or string');
        }

        return $this;
    }
459220
public function apply(DataQuery $query)
    {
        if ($this->aggregate) {
            throw new InvalidArgumentException(sprintf(
                'Aggregate functions can only be used with comparison filters. See %s',
                $this->fullName
            ));
        }

        return parent::apply($query);
    }
326081
public function append($query): self
    {
        if ($query instanceof UriComponentInterface) {
            $query = $query->getContent();
        }

        $pairs = array_merge($this->pairs, QueryString::parse($query, $this->separator, PHP_QUERY_RFC3986));
        if ($pairs === $this->pairs) {
            return $this;
        }

        $clone = clone $this;
        $clone->pairs = array_filter($pairs, [$this, 'filterEmptyValue']);

        return $clone;
    }
621076
public function withQuery($query)
    {
        $new = clone $this;
        try {
            $new->setQuery($query);
        } catch (InvalidArgumentException $ex) {
            throw new InvalidArgumentException('Invalid query provided.', null, $ex);
        }

        return $new;
    }
755790
protected function setQueryCount(string $query)
    {
        if ('' === $query) {
            throw new \InvalidArgumentException('setQueryCount require a valid string argument');
        }
        $this->queryCount = $query;
        $this->countMethod = self::COUNT_METHOD_QUERY;
    }
500963
public function withPath($path): UriInterface
   {
       if (!is_string($path)
        || !($parsedPath = $this->parsePath($path))) {
           throw new InvalidArgumentException(
               "Can't get with path: invalid expression");
       }
       return $this->with("path", $parsedPath);
   }
647158
final public function handle(Query $query): DTO
    {
        $supportedQueryType = $this->getSupportedQueryType();
        if (!\is_a($query, $supportedQueryType)) {
            throw new InvalidQueryException(\sprintf(
                'Query command must be a %s, %s given',
                $supportedQueryType,
                \get_class($query)
            ));
        }

        return $this->handleQuery($query);
    }
347112
protected function getBoolQuery(Query $query): BoolQuery
    {
        $boolQuery = $query->getQuery();
        if (!$boolQuery instanceof BoolQuery) {
            throw new InvalidArgumentException(sprintf(
                'Localized query expander available only with %s, got: %s',
                BoolQuery::class,
                get_class($boolQuery)
            ));
        }

        return $boolQuery;
    }
873648
public function query($query = NULL) {
        if (isset($query)) {
            $this->setQuery(self::cleanQuery($query));
            return $this;
        }
        return $this->getQuery();
    }
1344348
public function setQuery($query)
    {
        $this->query = $query;
        parse_str($this->query, $this->query_array);
        return $this;
    }
23725
public function fromSub($query, $as)
	{
		$bindings = [];
		if( $query instanceof Closure )
		{
			$callback = $query;
			$callback($query = $this->newQuery());
		}

		if( $query instanceof self )
		{
			$bindings = $query->getBindings();
			$query = $query->toSql();
		}
		else if( !is_string($query) )
		{
			throw new InvalidArgumentException;
		}

		$this->from = new Expression('('. $query .') as '.$this->grammar->wrap($as));
		$this->setBindings($bindings, 'from');

		return $this;
	}
649902
public function validateQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new InvalidArgumentException(
                'Query must be a string'
            );
        }

        if (strpos($query, '#') !== false) {
            throw new InvalidArgumentException(
                'Query must not contain a URI fragment'
            );
        }
    }
329238
public function search($query)
    {
        if ($this->hasSearch()) {

            $search = $this->search;

            // If it's a anonymous function
            if (!is_string($search) && is_callable($search)) {
                call_user_func($search, $this, $query);
            }
        }

        return $this;
    }
149566
public function get(string $query): ResponseInterface
    {
        return $this->client->request('get', $this->buildQuery($query), ['headers' => $this->getAuthorizationHeader()]);
    }
381487
protected function executeQuery($query)
    {
        $query   = null !== $this->getLocale() ? sprintf('%s&language=%s', $query, $this->getLocale()) : $query;
        $content = $this->getAdapter()->get($query)->getBody();

        if (!$data = json_decode($content, true)) {
            throw new NoResult(sprintf('Could not execute query: %s', $query));
        }

        if (!isset($data['Response']) && 'InvalidCredentials' === $data['subtype']) {
            throw new InvalidCredentials(sprintf('Invalid credentials: %s', $data['details']));
        } elseif (!isset($data['Response'])) {
            throw new NoResult(
                sprintf('Error type `%s` returned from api `%s`', $data['subtype'], $data['Details'])
            );
        }

        if (empty($data['Response']['View'])) {
            throw new NoResult(sprintf('Could not find results for given query: %s', $query));
        }

        $locations = $data['Response']['View'][0]['Result'];

        $results = array();
        foreach ($locations as $location) {
            $location       = $location['Location'];
            $coordinates    = isset($location['NavigationPosition'][0]) ? $location['NavigationPosition'][0] : $location['DisplayPosition'];
            $bounds         = $location['MapView'];
            $address        = $location['Address'];
            $additionalData = $location['Address']['AdditionalData'];

            $results[] = array_merge($this->getDefaults(), array(
                'latitude'     => $coordinates['Latitude']  ?: null,
                'longitude'    => $coordinates['Longitude'] ?: null,
                'bounds'       => array(
                    'south' => $bounds['BottomRight']['Latitude']  ?: null,
                    'west'  => $bounds['TopLeft']['Longitude']     ?: null,
                    'north' => $bounds['TopLeft']['Latitude']      ?: null,
                    'east'  => $bounds['BottomRight']['Longitude'] ?: null,
                ),
                'streetNumber' => isset($address['HouseNumber']) ? $address['HouseNumber'] : null,
                'streetName'   => isset($address['Street'])      ? $address['Street']      : null,
                'city'         => isset($address['City'])        ? $address['City']        : null,
                'cityDistrict' => isset($address['District'])    ? $address['District']    : null,
                'zipcode'      => isset($address['PostalCode'])  ? $address['PostalCode']  : null,
                'county'       => isset($address['County'])      ? $address['County']      : null,
                'regionCode'   => isset($address['State'])       ? $address['State']       : null,
                'countryCode'  => isset($address['Country'])     ? $address['Country']     : null,
                'region'       => $this->findByKey('StateName', $additionalData),
                'country'      => $this->findByKey('CountryName', $additionalData),
                'countyCode'   => null,
            ));
        }

        return $results;
    }
80386
public function addQuery($query)
    {
        $uri = clone $this;
        $query = is_array($query) ? http_build_query($query, PHP_QUERY_RFC3986) : $query;

        parse_str($query, $newQuery);

        if ( ! empty($uri->query)) {
            parse_str($uri->query, $oldQuery);
            $query = array_merge($oldQuery, $newQuery);
        } else {
            $query = $newQuery;
        }

        if (is_array($query)) {
            $uri->query = http_build_query($query, PHP_QUERY_RFC3986);
        }

        return $uri;
    }