Embryo/Http/Factory/UriFactory.php
public function createUriFromServer(array $server): UriInterface
        {
            // scheme, host, post, user, pass
            $scheme = (empty($server['HTTPS']) || $server['HTTPS'] === 'off') ? 'http' : 'https';
            $host   = (isset($server['HTTP_HOST'])) ? $server['HTTP_HOST'] : $server['SERVER_NAME'];
            $port   = (isset($server['SERVER_PORT'])) ? (int) $server['SERVER_PORT'] : 80;
            $user   = (isset($server['PHP_AUTH_USER'])) ? $server['PHP_AUTH_USER'] : '';
            $pass   = (isset($server['PHP_AUTH_PW'])) ? $server['PHP_AUTH_PW'] : '';
            
            // path
            $path = parse_url('http://example.com' . $server['REQUEST_URI'], PHP_URL_PATH);
            $path = rawurldecode($path);

            // query
            $query = (isset($server['QUERY_STRING'])) ? $server['QUERY_STRING'] : '';

            // fragment (not available in $_SERVER)
            $fragment = '';

            $uri = new Uri('');
            $uri = $uri->withScheme($scheme);
            $uri = $uri->withHost($host);
            $uri = $uri->withPort($port);
            $uri = $uri->withUserInfo($user, $pass);
            $uri = $uri->withPath($path);
            $uri = $uri->withQuery($query);
            $uri = $uri->withFragment($fragment);
            return $uri;
        }
public function createUriFromServer(array $server): UriInterface
        {
            // scheme, host, post, user, pass
            $scheme = (empty($server['HTTPS']) || $server['HTTPS'] === 'off') ? 'http' : 'https';
            $host   = (isset($server['HTTP_HOST'])) ? $server['HTTP_HOST'] : $server['SERVER_NAME'];
            $port   = (isset($server['SERVER_PORT'])) ? (int) $server['SERVER_PORT'] : 80;
            $user   = (isset($server['PHP_AUTH_USER'])) ? $server['PHP_AUTH_USER'] : '';
            $pass   = (isset($server['PHP_AUTH_PW'])) ? $server['PHP_AUTH_PW'] : '';
            
            // path
            $path = parse_url('http://example.com' . $server['REQUEST_URI'], PHP_URL_PATH);
            $path = rawurldecode($path);

            // query
            $query = (isset($server['QUERY_STRING'])) ? $server['QUERY_STRING'] : '';

            // fragment (not available in $_SERVER)
            $fragment = '';

            $uri = new Uri('');
            $uri = $uri->withScheme($scheme);
            $uri = $uri->withHost($host);
            $uri = $uri->withPort($port);
            $uri = $uri->withUserInfo($user, $pass);
            $uri = $uri->withPath($path);
            $uri = $uri->withQuery($query);
            $uri = $uri->withFragment($fragment);
            return $uri;
        }
public function createUriFromServer ( array $ server ) : UriInterface { // scheme, host, post, user, pass $ scheme = ( empty ( $ server [ 'HTTPS' ] ) || $ server [ 'HTTPS' ] === 'off' ) ? 'http' : 'https' ; $ host = ( isset ( $ server [ 'HTTP_HOST' ] ) ) ? $ server [ 'HTTP_HOST' ] : $ server [ 'SERVER_NAME' ] ; $ port = ( isset ( $ server [ 'SERVER_PORT' ] ) ) ? ( int ) $ server [ 'SERVER_PORT' ] : 80 ; $ user = ( isset ( $ server [ 'PHP_AUTH_USER' ] ) ) ? $ server [ 'PHP_AUTH_USER' ] : '' ; $ pass = ( isset ( $ server [ 'PHP_AUTH_PW' ] ) ) ? $ server [ 'PHP_AUTH_PW' ] : '' ; // path $ path = parse_url ( 'http://example.com' . $ server [ 'REQUEST_URI' ] , PHP_URL_PATH ) ; $ path = rawurldecode ( $ path ) ; // query $ query = ( isset ( $ server [ 'QUERY_STRING' ] ) ) ? $ server [ 'QUERY_STRING' ] : '' ; // fragment (not available in $_SERVER) $ fragment = '' ; $ uri = new Uri ( '' ) ; $ uri = $ uri -> withScheme ( $ scheme ) ; $ uri = $ uri -> withHost ( $ host ) ; $ uri = $ uri -> withPort ( $ port ) ; $ uri = $ uri -> withUserInfo ( $ user , $ pass ) ; $ uri = $ uri -> withPath ( $ path ) ; $ uri = $ uri -> withQuery ( $ query ) ; $ uri = $ uri -> withFragment ( $ fragment ) ; return $ uri ; }
Creates new Uri from array.

@param array $server
@return UriInterface
Creates new Uri from array .