You are here

public function Uri::withScheme in Zircon Profile 8

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

Return an instance with the specified scheme.

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

Implementations MUST support the schemes "http" and "https" case insensitively, and MAY accommodate other schemes if required.

An empty scheme is equivalent to removing the scheme.

Parameters

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

Return value

self A new instance with the specified scheme.

Throws

\InvalidArgumentException for invalid or unsupported schemes.

Overrides UriInterface::withScheme

File

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

Class

Uri
Basic PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function withScheme($scheme) {
  $scheme = $this
    ->filterScheme($scheme);
  if ($this->scheme === $scheme) {
    return $this;
  }
  $new = clone $this;
  $new->scheme = $scheme;
  $new->port = $new
    ->filterPort($new->scheme, $new->host, $new->port);
  return $new;
}