You are here

private function Uri::filterScheme in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::filterScheme()
  2. 8.0 vendor/guzzlehttp/psr7/src/Uri.php \GuzzleHttp\Psr7\Uri::filterScheme()
Same name and namespace in other branches
  1. 8 vendor/zendframework/zend-diactoros/src/Uri.php \Zend\Diactoros\Uri::filterScheme()

Filters the scheme to ensure it is a valid scheme.

Parameters

string $scheme Scheme name.:

Return value

string Filtered scheme.

2 calls to Uri::filterScheme()
Uri::parseUri in vendor/zendframework/zend-diactoros/src/Uri.php
Parse a URI into its parts, and set the properties
Uri::withScheme in vendor/zendframework/zend-diactoros/src/Uri.php
Return an instance with the specified scheme.

File

vendor/zendframework/zend-diactoros/src/Uri.php, line 525

Class

Uri
Implementation of Psr\Http\UriInterface.

Namespace

Zend\Diactoros

Code

private 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;
}