src/Http/Uri.php
public function withScheme($scheme): UriInterface
    {
        if (!in_array(strtolower($scheme), ['', 'http', 'https'])) {
            throw new InvalidArgumentException('Scheme must be one of : "", "http" or "https"');
        }

        $uri = clone $this;
        $uri->scheme = $scheme;

        return $uri;
    }
public function withScheme($scheme): UriInterface
    {
        if (!in_array(strtolower($scheme), ['', 'http', 'https'])) {
            throw new InvalidArgumentException('Scheme must be one of : "", "http" or "https"');
        }

        $uri = clone $this;
        $uri->scheme = $scheme;

        return $uri;
    }
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.
@return UriInterface A new instance with the specified scheme.
@throws \InvalidArgumentException for invalid or unsupported schemes.