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);
    }