classes/Url.php
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;
    }
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;
    }
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 ; }
Capture the URL from the SERVER super global

@see https://secure.php.net/manual/en/reserved.variables.server.php
@param array $server SERVER super global
@return static Captured URL
Capture the URL from the SERVER super global