public function withQuery(string $query): Uri
    {
        if ($query === $this->query) {
            return clone $this;
        }

        $query = $this->validateQuery($query);

        $new = clone $this;

        $new->query = $query;

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

        $query = $this->validateQuery($query);

        $new = clone $this;

        $new->query = $query;

        return $new;
    }
public function withQuery ( string $ query ) : Uri { if ( $ query === $ this -> query ) { return clone $ this ; } $ query = $ this -> validateQuery ( $ query ) ; $ new = clone $ this ; $ new -> query = $ query ; return $ new ; }
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.

@param string $query The query string to use with the new instance.

@throws \Valkyrja\HttpMessage\Exceptions\InvalidQuery for invalid query
strings.

@return static A new instance with the specified query string.
Return an instance with the specified query string .