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
        );
    }
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
        );
    }
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 ) ; }
Parse an URL

@throws InvalidUrlException if the URL is invalid
@return static
Parse an URL