public function withFragment($fragment) { $fragment = $this->filterFragment($fragment); if ($fragment === $this->fragment) { // Do nothing if no change was made. return clone $this; } $new = clone $this; $new->fragment = $fragment; return $new; }
public function testStripsFragmentPrefixIfPresent() { $uri = new Uri('http://example.com'); $new = $uri->withFragment('#/foo/bar'); $this->assertEquals('/foo/bar', $new->getFragment()); }