public function withScheme($scheme)
    {
        $scheme = strtolower($scheme);
        $pattern = new UriPattern();

        if (strlen($scheme) === 0 || $pattern->matchScheme($scheme)) {
            return $this->with('scheme', $scheme);
        }

        throw new \InvalidArgumentException("Invalid scheme '$scheme'");
    }