You are here

public function Uri::withHost in Zircon Profile 8

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

Return an instance with the specified host.

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

An empty host value is equivalent to removing the host.

Parameters

string $host The hostname to use with the new instance.:

Return value

self A new instance with the specified host.

Throws

\InvalidArgumentException for invalid hostnames.

Overrides UriInterface::withHost

File

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

Class

Uri
Basic PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function withHost($host) {
  if ($this->host === $host) {
    return $this;
  }
  $new = clone $this;
  $new->host = $host;
  return $new;
}