Sets the request scheme.

@param string $scheme The new request scheme.

@return static This request.

@throws \InvalidArgumentException If the scheme is not http or https.
435616
public function setScheme(string $scheme) : Request
    {
        $scheme = strtolower($scheme);

        if ($scheme === 'http') {
            $this->isSecure = false;
        } elseif ($scheme === 'https') {
            $this->isSecure = true;
        } else {
            throw new \InvalidArgumentException('The scheme must be http or https.');
        }

        return $this;
    }
659792
protected function filterScheme($scheme): string
    {
        if (!\is_string($scheme) && !\method_exists($scheme, '__toString')) {
            throw new \InvalidArgumentException('Uri scheme must be a string');
        }

        $scheme = \str_replace('://', '', \strtolower((string)$scheme));
        if (!isset(static::$validScheme[$scheme])) {
            throw new \InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
        }

        return $scheme;
    }
1148618
public function setScheme($scheme)
    {
        // validate scheme
        try {
            $scheme = new StringObject($scheme);
        } catch (\Exception $e) {
            throw new UrlObjectException($e->getMessage());
        }

        if (!$scheme->endsWith('://')) {
            $scheme->val($scheme->val() . '://');
        }

        // set the scheme
        $this->scheme = $scheme->trimRight('://')->val();
        $this->rebuildUrl();

        return $this;
    }
617167
public function withScheme(string $scheme): URI
    {
        $result = clone $this;
        $result->scheme = $this->filterScheme($scheme);

        return $result;
    }
167963
public function setMethod($method)
    {
        if(!in_array(strtoupper($method), $this->allowedMethods)) {
          throw new \InvalidArgumentException("The HTTP Client doesn't accept $method requests.");
        }

        $this->method = $method;
        return $this;
    }
795404
public function add(SecurityScheme $scheme) {
		$this->schemes->set($scheme->getId(), $scheme);
		return $this;
	}
1205376
public static function setForcedScheme($scheme = null)
    {
        if (! is_string($scheme) && ! is_null($scheme)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid scheme provided; must be an string or a null, "%s" received.',
                is_object($scheme) ? get_class($scheme) : gettype($scheme)
            ));
        }
        static::$forcedScheme = $scheme;
    }
1168070
public function createSchemeHeader($scheme)
    {
        $schemeObj = $this->getScheme($scheme);
        $value = $schemeObj->createResponseHeaderValue();

        return new HttpHeader($this->schemeHeader, trim($scheme . ' ' . $value));
    }
743124
private static function isAllowedScheme($scheme)
    {
        if (preg_match(AbstractRequest::HTTP, $scheme) === 1) {
            return 'http';
        } elseif (preg_match(AbstractRequest::FTP, $scheme) === 1) {
            return 'ftp';
        } elseif (preg_match(AbstractRequest::SSH, $scheme) === 1) {
            return 'ssh';
        } else {
            return false;
        }
    }
109337
protected function _filterScheme($scheme)
    {
        $scheme = strtolower($scheme);
        $scheme = preg_replace('#:(//)?$#', '', $scheme);

        if (empty($scheme)) {
            return '';
        }

        if (! array_key_exists($scheme, $this->_allowedSchemes)) {
            throw new InvalidArgumentException(sprintf(
                'Unsupported scheme "%s"; must be any empty string or in the set (%s)',
                $scheme,
                implode(', ', array_keys($this->_allowedSchemes))
            ));
        }

        return $scheme;
    }
1354085
protected function filterScheme($scheme)
    {
        $scheme = rtrim(strtolower($scheme), ':/');

        if (!preg_match('/^[a-z][a-z0-9.+-]*$/i', $scheme)) {
            throw new InvalidArgumentException('Scheme "%s" invalid or unsupported.', $scheme);
        }

        return $scheme;
    }
1275576
public function setScheme($scheme)
  {
    if ($this->isLocked()) {
      return $this->getObj()->setScheme($scheme)->setLocked();
    } else {
      return parent::setScheme($scheme);
    }
  }
1139597
public function setStrict($strict)
    {
        $allowed_values = $this->getStrictAllowableValues();
        if (!is_null($strict) && !in_array($strict, $allowed_values)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'strict', must be one of '%s'",
                    implode("', '", $allowed_values)
                )
            );
        }
        $this->container['strict'] = $strict;

        return $this;
    }
560352
public function setProtocol($protocol)
    {
        if (strlen($protocol) == 0) {
            throw new \InvalidArgumentException(sprintf('Cloud protocol should not be empty'));
        }

        $this->protocol = $protocol;

        return $this;
    }
424334
public function withScheme(string $scheme): self
    {
        $newConstraints = $this->constraints;
        $newConstraints[self::CONSTRAINT_SCHEME] = $scheme;
        return new static($newConstraints);
    }
599401
public function setProtocol($protocol) {

        if ( empty($protocol) || !in_array($protocol, $this->supported_protocols) ) throw new InvalidArgumentException('Invalid or unsupported RPC protocol');

        $this->protocol = $protocol;

        return $this;

    }
1270137
private function normalizeScheme($scheme)
    {
        if (!is_string($scheme) && !method_exists($scheme, '__toString')) {
            throw new InvalidArgumentException('Uri scheme must be a string');
        }

        $scheme = str_replace('://', '', strtolower((string) $scheme));
        if (!isset($this->validSchema[$scheme])) {
            throw new InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
        }

        return $scheme;
    }