private static function isValidUriAuthority(?string $authority): bool
    {
        if ($authority === null || $authority === '') {
            return true;
        }

        // http://tools.ietf.org/html/rfc3986#section-3.2
        // authority = [ userinfo "@" ] host [ ":" port ]
        $pattern = '/\A(?:([^@]*)@)?(\[[^\]]*\]|[^:]*)(?::(?:\d*))?\z/';
        preg_match($pattern, $authority, $matches);

        if (!self::isValidAuthUser((isset($matches[1]) && $matches[1]) ? $matches[1] : null)) {
            return false;
        }
        if (!self::isValidAuthHost((isset($matches[2]) && $matches[2]) ? $matches[2] : '')) {
            return false;
        }

        return true;
    }