public static function fromEnvironment(): UriInterface
    {
        parse_str($_SERVER['QUERY_STRING'] ?? '', $query);

        $uri = (new static())
            ->withScheme((isset($_SERVER['HTTPS']) === true && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http')
            ->withHost($_SERVER['HTTP_HOST'])
            ->withPort((int)$_SERVER['SERVER_PORT'])
            ->withPath(strtok($_SERVER['REQUEST_URI'], '?'))
            ->withQuery($query);

        if (array_key_exists('PHP_AUTH_USER', $_SERVER) === true) {
            $uri = $uri->withUser($_SERVER['PHP_AUTH_USER']);
        }

        if (array_key_exists('PHP_AUTH_PW', $_SERVER) === true) {
            $uri = $uri->withPass($_SERVER['PHP_AUTH_PW']);
        }

        return $uri;
    }