src/Http/Uri.php
public function withHost($host)
    {
        if (false) {
            // Invalid hostname ?
            throw new InvalidArgumentException('Hostname is not valid.');
        }

        $uri = clone $this;
        $uri->host = $host;

        return $uri;
    }
public function withHost($host)
    {
        if (false) {
            // Invalid hostname ?
            throw new InvalidArgumentException('Hostname is not valid.');
        }

        $uri = clone $this;
        $uri->host = $host;

        return $uri;
    }
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.

@param string $host The hostname to use with the new instance.
@return static A new instance with the specified host.
@throws \InvalidArgumentException for invalid hostnames.