You are here

public function Uri::withHost in Lockr 7.3

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

static A new instance with the specified host.

Throws

\InvalidArgumentException for invalid hostnames.

Overrides UriInterface::withHost

File

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

Class

Uri
PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

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