Provides a value object representing a URI for HTTP requests.
Instances of this class are considered immutable; all methods that
might change state are implemented such that they retain the internal
state of the current instance and return a new instance that contains the
changed state.
public function testStripsFragmentPrefixIfPresent() { $uri = new Uri('http://example.com'); $new = $uri->withFragment('#/foo/bar'); $this->assertEquals('/foo/bar', $new->getFragment()); }
/** * @group 48 */ public function testWithFragmentReturnsSameInstanceWhenFragmentDoesNotChange() { $uri = new Uri('http://example.com/test/path?foo=bar#/baz/bat'); $test = $uri->withFragment('/baz/bat'); $this->assertSame($uri, $test); }