Set the query part of the URL

@param QueryString|string|array $query Query to set

@return Url
3192
public function setQuery($query)
    {
        if (is_string($query)) {
            $output = null;
            parse_str($query, $output);
            $this->query = new QueryString($output);
        } elseif (is_array($query)) {
            $this->query = new QueryString($query);
        } elseif ($query instanceof QueryString) {
            $this->query = $query;
        }

        return $this;
    }
1049024
protected function buildUrl($url, $query = [])
    {
        $url = explode('?', $url, 2);
        if (count($url) == 2) {
            parse_str($url[1], $query0);
            $query = array_merge($query0, $query);
        }
        $query['apikey'] = $this->key;

        $url = $url[0];

        if (strpos($url, $this->baseUrl) === false) {
            $url = $this->baseUrl . $url;
        }

        return $this->uriFactory->createUri($url)
            ->withQuery(http_build_query($query));
    }
828114
public function urlPagination($pagination, array $query = [])
    {
        $query[MbDatabaseQueryBuilder::getPagination()] = $pagination;
        $query = array_replace($this->query(), $query);

        return $this->url() . '?' . http_build_query($query);
    }
812864
public function withQuery(string $query): URI
    {
        $result = clone $this;
        $result->query = $this->filterQuery($query);

        return $result;
    }
342641
public static function mergeQuery($url, array $query)
    {
        // No query.
        if (!$query) {
            return $url;
        }

        $queryString = http_build_query($query);
        $qPos = strpos($url, '?');
        $hashPos = strpos($url, '#');
        $pos = strlen($url);
        $hasQuery = $qPos !== false && ($qPos < $hashPos || $hashPos === false);

        if ($qPos || $hashPos) {
            $pos = $hasQuery ? $qPos + 1 : $hashPos;
        }

        $prefix = substr($url, 0, $pos);
        $suffix = substr($url, $pos);

        return sprintf(
            '%s%s%s%s%s',
            $prefix,
            $hasQuery ? '' : '?',
            $queryString,
            $hasQuery ? '&' : '',
            $suffix
        );
    }
311748
public static function fromString($query, array $data = [])
    {
        $url = parse_url($query);
        $query = isset($url['query']) ? $url['query'] : $url['path'];
        parse_str($query, $data);

        return new QueryString($data);
    }
1135740
protected function prepareRequestUrl(array $query)
    {
        $path = isset($query['from']['path']) ? $query['from']['path'] : null;

        $wheres = isset($query['wheres']) ? $query['wheres'] : null;

        $baseUrl = $this->host.$path;

        // Here we validate that there are any wheres in the
        // request. When none are provided we will return the
        // Request Url without the question mark.
        if (! is_null($wheres)) {
            return $baseUrl.'?'.$wheres;
        }

        return $baseUrl;
    }
281314
public function setQueryString(string $queryString) : Request
    {
        $this->queryString = (string) $queryString;
        parse_str($this->queryString, $this->query);

        return $this->updateRequestUri();
    }
378140
public function withQueryString(QueryString $query): self
    {
        $url = Structure::fromString((string) $this)
            ->withQuery(
                Query::fromString((string) $query->substring(1))
            )
            ->withFragment(new NullFragment);

        return new self(
            (string) $url
        );
    }
900836
protected static function appendQuery(string $uri, array $query = []): string {
        if (!empty($query)) {
            $qs = http_build_query($query);
            $uri .= (strpos($uri, '?') === false ? '?' : '&').$qs;
        }
        return $uri;
    }
722845
protected function mergeOrReplaceQuery($query)
    {
        if (is_array($query)) {
            return array_merge($this->query, $query);
        }

        if (!is_string($query)) {
            throw new InvalidArgumentException('Query has to be array or string not '.gettype($query));
        }

        if ($query === '') {
            return [];
        }

        $normalized = ltrim($query, '?');

        $items = [];
        parse_str($normalized, $items);

        // If the query starts with a ? overwrite the complete url
        if ($query[0] == '?') {
            return $items;
        }

        return array_merge($this->query, $items);
    }
72273
public function send(array $query = []): Response
    {
        $endpoint = new Put();
        $endpoint->setBody($this->toArray());
        $endpoint->setParams($query);

        return $this->getType()->requestEndpoint($endpoint);
    }
964453
protected function generateLoginUrl($query)
    {
        //if there is a scope
        if (!is_null($this->scope)) {
            //if scope is in array
            if (is_array($this->scope)) {
                $this->scope = implode(' ', $this->scope);
            }
            //add scope to the query
            $query['scope'] = $this->scope;
        }
        //if there is state
        if (!is_null($this->state)) {
            //add state to the query
            $query['state'] = $this->state;
        }
        //if there is display
        if (!is_null($this->display)) {
            //add state to the query
            $query['display'] = $this->display;
        }
        //generate a login url
        return $this->requestUrl.'?'.http_build_query($query);
    }
1036530
public function get($url, $query = false)
    {
        $this->initializeRequest();

        if (is_array($query)) {
            $url .= '?' . http_build_query($query);
        }

        curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($this->curl, CURLOPT_URL, $url);
        curl_setopt($this->curl, CURLOPT_POST, false);
        curl_setopt($this->curl, CURLOPT_PUT, false);
        curl_setopt($this->curl, CURLOPT_HTTPGET, true);
        curl_exec($this->curl);

        return $this->handleResponse();
    }
1334224
public final function withQuery($query): UriInterface
   {
       if (!is_string($query)) {
           throw new InvalidArgumentException(
               "Can't get with query: invalid query string");
       }
       return $this->with("query", $this->parseQuery($query));
   }
597019
public function setEagerLoaded($query)
	{
		if( ! empty($this->getEagerLoad()))
		{
			$query = $query->with($this->getEagerLoad());
		}

		return $query;
	}
947019
public function sendSparqlUpdateQuery($url, $query)
    {
        // because you can't just fire multiple requests with the same CURL class instance
        // we have to be creative and re-create the class everytime a request is to be send.
        // FYI: https://github.com/php-curl-class/php-curl-class/issues/326
        $class = get_class($this->httpClient);
        $phpVersionToOld = version_compare(phpversion(), '5.5.11', '<=');
        // only reinstance the class if its not mocked
        if ($phpVersionToOld && false === strpos($class, 'Mockery')) {
            $this->httpClient = new $class;
        }

        // TODO extend Accept headers to further formats
        $this->httpClient->setHeader('Accept', 'application/sparql-results+json');
        $this->httpClient->setHeader('Content-Type', 'application/sparql-update');

        return $this->httpClient->get($url, array('query' => $query));
    }