withoutQueryValue() public static method

Any existing query string values that exactly match the provided key are removed.
public static withoutQueryValue ( Psr\Http\Message\UriInterface $uri, string $key ) : Psr\Http\Message\UriInterface
$uri Psr\Http\Message\UriInterface URI to use as a base.
$key string Query string key to remove.
return Psr\Http\Message\UriInterface
Exemplo n.º 1
0
 public function testAddAndRemoveQueryValues()
 {
     $uri = new Uri('http://foo.com/bar');
     $uri = Uri::withQueryValue($uri, 'a', 'b');
     $uri = Uri::withQueryValue($uri, 'c', 'd');
     $uri = Uri::withQueryValue($uri, 'e', null);
     $this->assertEquals('a=b&c=d&e', $uri->getQuery());
     $uri = Uri::withoutQueryValue($uri, 'c');
     $uri = Uri::withoutQueryValue($uri, 'e');
     $this->assertEquals('a=b', $uri->getQuery());
     $uri = Uri::withoutQueryValue($uri, 'a');
     $uri = Uri::withoutQueryValue($uri, 'a');
     $this->assertEquals('', $uri->getQuery());
 }
Exemplo n.º 2
0
 public function testWithoutQueryValueHandlesEncoding()
 {
     // It also tests that the case of the percent-encoding does not matter,
     // i.e. both lowercase "%3d" and uppercase "%5E" can be removed.
     $uri = (new Uri())->withQuery('E%3dmc%5E2=einstein&foo=bar');
     $uri = Uri::withoutQueryValue($uri, 'E=mc^2');
     $this->assertSame('foo=bar', $uri->getQuery(), 'Handles key in decoded form');
     $uri = (new Uri())->withQuery('E%3dmc%5E2=einstein&foo=bar');
     $uri = Uri::withoutQueryValue($uri, 'E%3Dmc%5e2');
     $this->assertSame('foo=bar', $uri->getQuery(), 'Handles key in encoded form');
 }