/**
* Get a Uri populated with values from $_SERVER.
*/
public static function getUriFromGlobals(): UriInterface
{ $uri =
new Uri(''
);
$uri =
$uri->
withScheme(!
empty($_SERVER['HTTPS'
]) &&
$_SERVER['HTTPS'
] !== 'off' ? 'https' : 'http'
);
$hasPort = false;
if (isset($_SERVER['HTTP_HOST'
])) { [$host,
$port] = self::
extractHostAndPortFromAuthority($_SERVER['HTTP_HOST'
]);
if ($host !== null
) { $uri =
$uri->
withHost($host);
} if ($port !== null
) { $hasPort = true;
$uri =
$uri->
withPort($port);
} } elseif (isset($_SERVER['SERVER_NAME'
])) { $uri =
$uri->
withHost($_SERVER['SERVER_NAME'
]);
} elseif (isset($_SERVER['SERVER_ADDR'
])) {