You are here

public function Uri::withPort in Lockr 7.3

Return an instance with the specified port.

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

Implementations MUST raise an exception for ports outside the established TCP and UDP port ranges.

A null value provided for the port is equivalent to removing the port information.

Parameters

null|int $port The port to use with the new instance; a null value: removes the port information.

Return value

static A new instance with the specified port.

Throws

\InvalidArgumentException for invalid ports.

Overrides UriInterface::withPort

File

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

Class

Uri
PSR-7 URI implementation.

Namespace

GuzzleHttp\Psr7

Code

public function withPort($port) {
  $port = $this
    ->filterPort($port);
  if ($this->port === $port) {
    return $this;
  }
  $new = clone $this;
  $new->port = $port;
  $new
    ->removeDefaultPort();
  $new
    ->validateState();
  return $new;
}