public function withPort($port)
    {
        if ($port !== null) {
            $port = (int) $port;

            if (max(0, min(65535, $port)) !== $port) {
                throw new \InvalidArgumentException("Invalid port number '$port'");
            }
        }

        return $this->with('port', $port);
    }
public function withPort($port)
    {
        if ($port !== null) {
            $port = (int) $port;

            if (max(0, min(65535, $port)) !== $port) {
                throw new \InvalidArgumentException("Invalid port number '$port'");
            }
        }

        return $this->with('port', $port);
    }
public function withPort ( $ port ) { if ( $ port !== null ) { $ port = ( int ) $ port ; if ( max ( 0 , min ( 65535 , $ port ) ) !== $ port ) { throw new \ InvalidArgumentException ( "Invalid port number '$port'" ) ; } } return $ this -> with ( 'port' , $ port ) ; }
Returns a URI instance with the specified port.

A null value can be used to remove the port number. Note that if an
invalid port number is provided (a number less than 0 or more than
65535), an exception will be thrown.

@param int|null $port The port to use with the new instance
@return static A new instance with the specified port
@throws \InvalidArgumentException If the port is invalid
Returns a URI instance with the specified port .