You are here

public function Uri::withFragment in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::withFragment()
  2. 8 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::withFragment()
Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::withFragment()

Return an instance with the specified URI fragment.

This method MUST retain the state of the current instance, and return an instance that contains the specified URI fragment.

Users can provide both encoded and decoded fragment characters. Implementations ensure the correct encoding as outlined in getFragment().

An empty fragment value is equivalent to removing the fragment.

Parameters

string $fragment The fragment to use with the new instance.:

Return value

self A new instance with the specified fragment.

Overrides UriInterface::withFragment

File

vendor/guzzlehttp/psr7/src/Uri.php, line 419

Class

Uri
Basic PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function withFragment($fragment) {
  if (substr($fragment, 0, 1) === '#') {
    $fragment = substr($fragment, 1);
  }
  $fragment = $this
    ->filterQueryAndFragment($fragment);
  if ($this->fragment === $fragment) {
    return $this;
  }
  $new = clone $this;
  $new->fragment = $fragment;
  return $new;
}