original_string: static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
      {
          $components = parse_url($url);
  
          if ($components === false) {
              throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
          }
  
          $query = [];
  
          if (isset($components['query'])) {
              parse_str($components['query'], $query);
          }
  
          return new static(
              $components['scheme'] ?? null,
              $components['host'] ?? null,
              $components['port'] ?? null,
              $components['path'] ?? '',
              $query,
              $components['fragment'] ?? null,
              $preferredFormat
          );
      }
code: static function parse(string $url, ?int $preferredFormat = self::ABSOLUTE)
      {
          $components = parse_url($url);
  
          if ($components === false) {
              throw new InvalidUrlException(sprintf('The given URL "%s" is invalid', $url));
          }
  
          $query = [];
  
          if (isset($components['query'])) {
              parse_str($components['query'], $query);
          }
  
          return new static(
              $components['scheme'] ?? null,
              $components['host'] ?? null,
              $components['port'] ?? null,
              $components['path'] ?? '',
              $query,
              $components['fragment'] ?? null,
              $preferredFormat
          );
      }
code_tokens: static function parse ( string $ url , ? int $ preferredFormat = self :: ABSOLUTE ) { $ components = parse_url ( $ url ) ; if ( $ components === false ) { throw new InvalidUrlException ( sprintf ( 'The given URL "%s" is invalid' , $ url ) ) ; } $ query = [ ] ; if ( isset ( $ components [ 'query' ] ) ) { parse_str ( $ components [ 'query' ] , $ query ) ; } return new static ( $ components [ 'scheme' ] ?? null , $ components [ 'host' ] ?? null , $ components [ 'port' ] ?? null , $ components [ 'path' ] ?? '' , $ query , $ components [ 'fragment' ] ?? null , $ preferredFormat ) ; }
docstring: Parse an URL
  
  @throws InvalidUrlException if the URL is invalid
  @return static
docstring_tokens: Parse an URL