code: public static function instance(array $server)
      {
          $secure = isset($server['HTTPS']) ? $server['HTTPS'] : 'off';
  
          $http = $secure === 'off' ? 'http' : 'https';
  
          $url = $http . '://' . $server['SERVER_NAME'];
  
          $url .= (string) $server['SERVER_PORT'];
  
          return new Uri($url . $server['REQUEST_URI']);
      }
docs: Generates a \Psr\Http\Message\UriInterface from server variables.
  
  @param  array $server
  @return \Psr\Http\Message\UriInterface