public function withFragment($fragment)
{
if (!is_string($fragment)) {
throw new InvalidArgumentException(sprintf('%s expects a string argument; received %s', __METHOD__, is_object($fragment) ? get_class($fragment) : gettype($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;
}