src/Valkyrja/HttpMessage/NativeUri.php
public function withScheme(string $scheme): Uri
    {
        if ($scheme === $this->scheme) {
            return clone $this;
        }

        $scheme = $this->validateScheme($scheme);

        $new = clone $this;

        $new->scheme = $scheme;

        return $new;
    }
public function withScheme(string $scheme): Uri
    {
        if ($scheme === $this->scheme) {
            return clone $this;
        }

        $scheme = $this->validateScheme($scheme);

        $new = clone $this;

        $new->scheme = $scheme;

        return $new;
    }
Return an instance with the specified scheme.

This method MUST retain the state of the current instance, and return
an instance that contains the specified scheme.

Implementations MUST support the schemes "http" and "https" case
insensitively, and MAY accommodate other schemes if required.

An empty scheme is equivalent to removing the scheme.

@param string $scheme The scheme to use with the new instance.

@throws \Valkyrja\HttpMessage\Exceptions\InvalidScheme for invalid or
unsupported schemes.

@return static A new instance with the specified scheme.