public function withPort($port = null)
    {
        if ($port !== null && $port < 1 && $port > 65535) {
            throw new InvalidArgumentException(
                'Port must be null or an integer between 1 and 65535'
            );
        }

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

        return $uri;
    }