public static function createFromString(string $uri): self
    {
        if (!\is_string($uri) && !\method_exists($uri, '__toString')) {
            throw new \InvalidArgumentException('Uri must be a string');
        }

        $parts    = \parse_url($uri);
        $scheme   = $parts['scheme'] ?? '';
        $user     = $parts['user'] ?? '';
        $pass     = $parts['pass'] ?? '';
        $host     = $parts['host'] ?? '';
        $port     = $parts['port'] ?? null;
        $path     = $parts['path'] ?? '';
        $query    = $parts['query'] ?? '';
        $fragment = $parts['fragment'] ?? '';

        return new static($scheme, $host, $port, $path, $query, $fragment, $user, $pass);
    }
public static function createFromString(string $uri): self
    {
        if (!\is_string($uri) && !\method_exists($uri, '__toString')) {
            throw new \InvalidArgumentException('Uri must be a string');
        }

        $parts    = \parse_url($uri);
        $scheme   = $parts['scheme'] ?? '';
        $user     = $parts['user'] ?? '';
        $pass     = $parts['pass'] ?? '';
        $host     = $parts['host'] ?? '';
        $port     = $parts['port'] ?? null;
        $path     = $parts['path'] ?? '';
        $query    = $parts['query'] ?? '';
        $fragment = $parts['fragment'] ?? '';

        return new static($scheme, $host, $port, $path, $query, $fragment, $user, $pass);
    }
public static function createFromString ( string $ uri ) : self { if ( ! \ is_string ( $ uri ) && ! \ method_exists ( $ uri , '__toString' ) ) { throw new \ InvalidArgumentException ( 'Uri must be a string' ) ; } $ parts = \ parse_url ( $ uri ) ; $ scheme = $ parts [ 'scheme' ] ?? '' ; $ user = $ parts [ 'user' ] ?? '' ; $ pass = $ parts [ 'pass' ] ?? '' ; $ host = $ parts [ 'host' ] ?? '' ; $ port = $ parts [ 'port' ] ?? null ; $ path = $ parts [ 'path' ] ?? '' ; $ query = $ parts [ 'query' ] ?? '' ; $ fragment = $ parts [ 'fragment' ] ?? '' ; return new static ( $ scheme , $ host , $ port , $ path , $ query , $ fragment , $ user , $ pass ) ; }
Create new Uri from string.
@param  string $uri Complete Uri string
(i.e., https://user:pass@host:443/path?query).
@return self
@throws \InvalidArgumentException
Create new Uri from string .