Filters the scheme to ensure it is a valid scheme.

@param string $scheme Scheme name.

@return string Filtered scheme.
491040
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;
    }
936753
public static function setScheme($scheme) {

		if(false === is_string($scheme)) {
  			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($scheme)), E_USER_ERROR);
  		}

		$_SERVER['REQUEST_SCHEME'] = $scheme;
	}
644005
protected function convertToFilterFormat($filter)
    {
        $filter = trim($filter);
        if (substr($filter, 0, 1) != '(') {
            $filter = '(' . $filter;
        }
        if (substr($filter, -1) != ')') {
            $filter = $filter . ')';
        }
        return $filter;
    }
1194187
public function loaderByScheme($scheme)
    {
        if (!array_key_exists($scheme, $this->loaders)) {
            throw new Exception\UndefinedLoaderException($scheme);
        }

        return $this->loaders[$scheme];
    }
1020137
public function schemeClass($scheme)
    {
        if (null === $scheme) {
            return $this->defaultClass();
        }

        $scheme = strtolower($scheme);
        $schemeClasses = $this->schemeClasses();
        if (!array_key_exists($scheme, $schemeClasses)) {
            return $this->defaultClass();
        }

        return $schemeClasses[$scheme];
    }
1285800
protected function getScheme(?string $scheme, ?string $domain = null) : string
    {
        if ($scheme === null || $scheme === '//') {
            return $this->tryGuessScheme($domain);
        }

        return $this->trim($scheme, ':/') . '://';
    }
367700
public function scheme($raw = false)
    {
        if (!$raw) {
            $scheme = '';
            if ($this->scheme) {
                $scheme = $this->scheme . '://';
            } elseif ($this->host) {
                $scheme = '//';
            }

            return $scheme;
        }

        return $this->scheme;
    }
1307874
public function parse($spec)
    {
        preg_match(Url::SCHEME_PATTERN, $spec, $schemeMatches);

        if (empty($schemeMatches)) {
            $spec = 'http://' . preg_replace('#^//#', '', $spec, 1);
        }

        return parse_url($spec);
    }
671046
public function filterScheme($scheme)
    {
        $valids = [
            ''      => true,
            'http'  => true,
            'https' => true,
        ];
        $scheme = str_replace('://', '', strtolower((string) $scheme));
        if (!isset($valids[$scheme])) {
            throw new \InvalidArgumentException('Uri scheme must be one of: "", "https", "http"');
        }

        return $scheme;
    }
476329
def is_scheme(scheme, slashes=True):
    """"""
    scheme = scheme.lower()
    if slashes:
        return scheme in URI_SCHEMES
    return scheme in URI_SCHEMES and not URI_SCHEMES[scheme]
342230
private function _filterScheme($scheme)
    {
        $scheme = strtolower($scheme);
        $scheme = preg_replace('#:(//)?$#', '', $scheme);

        if (!preg_match('/\A[a-z][a-z0-9\+\-\.]+\z/', $scheme)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid scheme "%s" specified; must be a valid RFC 3986 scheme',
                $scheme
            ));
        }

        if ($scheme && !in_array($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;
    }
590957
public function getApiUrl($scheme = true)
    {
        return Url::toRoute([
            '/wechat/' . Yii::$app->getModule('wechat')->apiRoute,
            'id' => $this->id
        ], $scheme);
    }
196495
public function EntityContexts( $entity, $scheme = null )
	{
		$filtered = array_filter( $this->contexts, function ( $context ) use( $entity, $scheme ) {

			// The context may be invalid in which case exclude
			if ( ! isset( $context['entity']['identifier']['value'] ) ) return false;

			if ( $context['entity']['identifier']['value'] == $entity )
			{
				// If supplied also check the scheme
				return $scheme != null && isset( $context['entity']['identifier']['scheme'] )
				? ( strtolower( $scheme ) == strtolower( $context['entity']['identifier']['scheme'] ) )
				: true;
			}

			return false;
		} );

		return new ContextsFilter( $this->instance, $filtered );
	}
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;
    }
1069279
public function addScheme(Route\Scheme $scheme)
    {
        foreach ($scheme->getPrefixes() as $prefix) {
            $this->schemePrefixes[$prefix] = $scheme;
        }
        foreach ($scheme->getKeys() as $key) {
            $this->schemeKeys[$key] = $scheme;
        }
    }
112763
protected static function normalizeScheme(?string $scheme): string
    {
        if (!static::isValidScheme($scheme)) {
            $message = sprintf('Invalid URI scheme: %s', VarPrinter::toString($scheme));
            throw new DomainException($message);
        }

        return strtolower($scheme);
    }
112203
function setScheme($scheme)
    {
        if ($scheme !== null)
            $scheme = $this->_filterScheme((string) $scheme);

        $this->scheme = $scheme;
        return $this;
    }