You are here

public function Uri::withQuery in Lockr 7.3

Return an instance with the specified query string.

This method MUST retain the state of the current instance, and return an instance that contains the specified query string.

Users can provide both encoded and decoded query characters. Implementations ensure the correct encoding as outlined in getQuery().

An empty query string value is equivalent to removing the query string.

Parameters

string $query The query string to use with the new instance.:

Return value

static A new instance with the specified query string.

Throws

\InvalidArgumentException for invalid query strings.

Overrides UriInterface::withQuery

File

vendor/guzzlehttp/psr7/src/Uri.php, line 502

Class

Uri
PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function withQuery($query) {
  $query = $this
    ->filterQueryAndFragment($query);
  if ($this->query === $query) {
    return $this;
  }
  $new = clone $this;
  $new->query = $query;
  return $new;
}