Filters the scheme to ensure it is a valid scheme.

@param string $scheme Scheme name.

@return string Filtered scheme.
@throws \InvalidArgumentException
482669
private function filterScheme($scheme)
    {
        $scheme = \strtolower($scheme);
        $scheme = \preg_replace('#:(//)?$#', '', $scheme);

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

        if (!isset(static::$schemes[$scheme])) {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported scheme "%s"; must be any empty string or in the set (%s)',
                $scheme,
                \implode(', ', \array_keys(static::$schemes))
            ));
        }

        return $scheme;
    }
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;
        }
    }
1200190
public function setScheme($scheme)
    {
        // Remove the default port if one is specified
        if ($this->port && isset(self::$defaultPorts[$this->scheme]) &&
            self::$defaultPorts[$this->scheme] == $this->port
        ) {
            $this->port = null;
        }

        $this->scheme = $scheme;

        return $this;
    }
902407
public function authorization(string $scheme, string $value): HttpRequest
    {
        if (empty($scheme)) {
            throw new \InvalidArgumentException("Scheme was null or empty");
        }
        if (empty($value)) {
            throw new \InvalidArgumentException("Value was null or empty");
        }
        return $this->header("Authorization", $scheme . " " . $value);
    }
650483
protected function filterMethod($method)
    {
        if ($method === null) {
            return $method;
        }

        if (!is_string($method)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Unsupported HTTP method; must be a string, received %s',
                    is_object($method) ? get_class($method) : gettype($method)
                )
            );
        }

        $method = strtoupper($method);

        if (!in_array($method, self::$validMethods)) {
            throw new \InvalidArgumentException(sprintf('Invalid HTTP method "%s" provided', $method));
        }

        return $method;
    }
804543
protected static function filterScheme($scheme)
    {
        if (! is_string($scheme)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid scheme provided; must be a string argument; ; received %s',
                (is_object($scheme) ? get_class($scheme) : gettype($scheme))
            ));
        }

        $scheme = str_replace('://', '', strtolower($scheme));

        if (! isset(static::$standardSchemes[$scheme])) {
            throw new InvalidArgumentException(sprintf(
                'Unsupported scheme "%s"; must be any empty string or in the set (%s)',
                $scheme,
                implode(', ', array_keys(static::$standardSchemes))
            ));
        }

        return $scheme;
    }
1355868
public function getFilter(string $name) : BsonFilter
    {
        if (! $this->isEnabled($name)) {
            throw new InvalidArgumentException("Filter '" . $name . "' is not enabled.");
        }
        return $this->enabledFilters[$name];
    }
945585
protected function setScheme($scheme)
    {
        $this->uriString = null;

        $this->scheme = strtolower(rtrim($scheme, ':/'));

        return $this;
    }
806061
public function setAllowedSchemes($allowedSchemes)
    {
        if (empty($allowedSchemes)) {
            throw new \InvalidArgumentException("Allowed schemes cannot be empty.");
        }

        $allowedSchemes = (array) $allowedSchemes;
        $c = count($allowedSchemes);
        for ($i = 0; $i < $c; ++$i) {
            if (empty($allowedSchemes[$i])) {
                throw new \InvalidArgumentException("An allowed scheme cannot be empty.");
            } elseif (!preg_match(static::SCHEME_PATTERN, $allowedSchemes[$i])) {
                throw new \InvalidArgumentException("Allowed scheme [{$allowedSchemes[$i]}] contains illegal characters (see RFC3986).");
            }
        }
        $this->allowedSchemes = $allowedSchemes;

        return $this;
    }
753521
protected function marshalScheme($scheme): ? string
    {
        if ( null === $scheme ) {
            return null;
        }

        if ( ! is_string($scheme) ) {
            throw new UriException(
                'Scheme must be a string'
            );
        }

        return strtolower($scheme);
    }
142449
public function getFilesystem($scheme)
    {
        if (empty($scheme) || !is_string($scheme)) {
            throw new RuntimeError('Scheme (prefix) of filesystem must be a non-empty string.');
        }

        if (!StringToolkit::endsWith($scheme, self::SCHEME_SEPARATOR)) {
            $scheme .= self::SCHEME_SEPARATOR;
        }

        return $this->mount_manager->getAdapter($scheme);
    }
731620
public function withFilter($filter) {
        if (!in_array($filter, [self::ALL, self::ANY, self::SOME, self::EXISTS, self::NOT_EXISTS, self::IN, self::NOT_IN], true)) {
            throw new InvalidArgumentException('Invalid filter type for sub-query');
        }

        $this->_filter = $filter;

        return $this;
    }
478232
protected function getPort($scheme)
    {
        if ($scheme == self::SCHEME_WEBSOCKET) {
            return 80;
        } elseif ($scheme == self::SCHEME_WEBSOCKET_SECURE) {
            return 443;
        } elseif ($scheme == self::SCHEME_UNDERLYING) {
            return 80;
        } elseif ($scheme == self::SCHEME_UNDERLYING_SECURE) {
            return 443;
        } else {
            throw new InvalidArgumentException('Unknown websocket scheme');
        }
    }
38842
public function enable(string $name) : BsonFilter
    {
        if (! $this->has($name)) {
            throw new InvalidArgumentException("Filter '" . $name . "' does not exist.");
        }

        if (! $this->isEnabled($name)) {
            $filterClass      = $this->config->getFilterClassName($name);
            $filterParameters = $this->config->getFilterParameters($name);
            $filter           = new $filterClass($this->dm);

            foreach ($filterParameters as $param => $value) {
                $filter->setParameter($param, $value);
            }

            $this->enabledFilters[$name] = $filter;
        }

        return $this->enabledFilters[$name];
    }
412883
public function add_filter_by_key( FilterInterface $filter, $key ) {

		if ( ! is_scalar( $key ) ) {
			throw new Exception\InvalidArgumentException( 'key should be a scalar value.' );
		}

		$key = (string) $key;

		if ( ! isset ( $this->filters_by_key[ $key ] ) ) {
			$this->filters_by_key[ $key ] = [ ];
		}

		$this->filters_by_key[ $key ][] = $filter;

		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;
    }
394037
private function parseScheme(array $locationParts): void
    {
        if (! $this->isValidScheme($locationParts['scheme'])) {
            throw new InvalidArgumentException(
                sprintf('"%s" is not a valid scheme.', $locationParts['scheme'])
            );
        }

        $this->scheme = strtolower($locationParts['scheme']);
    }