protected function filterPort(?int $port): ?int
    {
        if ((integer) $port >= 0 && (integer) $port <= 65535) {
            return $port;
        }

        throw new InvalidArgumentException('Uri port must be null or an integer between 1 and 65535 (inclusive)');
    }