public static function capture(array $server = null)
    {
        if (!$server) {
            $server = $_SERVER;
        }

        $source = 'http:';
        if (isset($server['HTTPS']) && $server['HTTPS'] && $server['HTTPS'] != 'off') {
            $source = 'https:';
        }
        if (isset($server['HTTP_HOST'])) {
            $source .= '//' . $server['HTTP_HOST'];
        }
        if (isset($server['REQUEST_URI'])) {
            $source .= $server['REQUEST_URI'];
        }

        $url = new static($source);
        $url->username = $server['PHP_AUTH_USER'] ?? null;
        $url->password = $server['PHP_AUTH_PW'] ?? null;

        return $url;
    }