@param string|null $scheme
@param string $path

@return string
341035
protected function toString(?string $scheme, string $path): string
    {
        if ($scheme) {
            return $scheme . '://' . $path;
        }

        return $path;
    }
590673
protected static function _createUriString($scheme, $authority, $path, $query, $fragment)
    {
        $uri = '';

        if (! empty($scheme)) {
            $uri .= sprintf('%s://', $scheme);
        }

        if (! empty($authority)) {
            $uri .= $authority;
        }

        if ($path) {
            if (empty($path) || '/' !== substr($path, 0, 1)) {
                $path = '/' . $path;
            }

            $uri .= $path;
        }

        if ($query) {
            $uri .= sprintf('?%s', $query);
        }

        if ($fragment) {
            $uri .= sprintf('#%s', $fragment);
        }

        return $uri;
    }
981029
private function formatScheme(?string $scheme): ?string
    {
        if ('' === $scheme || null === $scheme) {
            return $scheme;
        }

        $formatted_scheme = strtolower($scheme);
        if (1 === preg_match(self::REGEXP_SCHEME, $formatted_scheme)) {
            return $formatted_scheme;
        }

        throw new SyntaxError(sprintf('The scheme `%s` is invalid', $scheme));
    }
857989
public function getRoute($path, $domain = null, $scheme = null)
    {
        $uri = ($scheme ?? $this->scheme) . '://' . ($domain ?? $this->domain) . $path;

        return $this->find($uri);
    }
137087
public static function filterScheme($scheme)
    {
        $scheme = strtolower($scheme);
        $scheme = preg_replace('#:(//)?$#', '', $scheme);

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

        return $scheme;
    }
48939
public function Path($Path = NULL) {
      if (is_string($Path)) {
         $Result = $this->_ParsedRequestElement('Path', $Path);
      } else {
         $Result = $this->_ParsedRequestElement('Path');
         if ($Path === TRUE) {
            // Encode the path.
            $Parts = explode('/', $Result);
            $Parts = array_map('urlencode', $Parts);
            $Result = implode('/', $Parts);
         }
      }
      
      return $Result;
   }
996208
public static function tryParse(string $scheme): ?SchemeInterface
    {
        if (!self::myParse($scheme, $result, $type, $defaultPort)) {
            return null;
        }

        return new self($result, $type, $defaultPort);
    }
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);
    }
234456
protected function getRootUrl($scheme, $root = null)
	{
		if (is_null($root))
		{
			if (is_null($this->cachedRoot))
			{
				$this->cachedRoot = $this->forcedRoot ?: $this->request->root();
			}

			$root = $this->cachedRoot;
		}

		$start = starts_with($root, 'http://') ? 'http://' : 'https://';

		return preg_replace('~'.$start.'~', $scheme, $root, 1);
	}
1069598
private function filterScheme(string $scheme): string
    {
        $result = strtolower($scheme);
        if (isset(self::$knownPorts[$result])) {
            return $result;
        }

        $result = preg_replace('#:(//)?$#', '', $result);
        if (!preg_match('#^[a-z][a-z0-9\+\-\.]*$#i', $result)) {
            throw new \InvalidArgumentException(sprintf('Invalid scheme "%s".', $scheme));
        }

        return $result;
    }
518061
public PathImpl get(String scheme)
  {
    ConcurrentHashMap<String,SchemeRoot> map = getMap();
    
    SchemeRoot root = map.get(scheme);

    if (root == null) {
      PathImpl rootPath = createLazyScheme(scheme);
      
      if (rootPath != null) {
        map.putIfAbsent(scheme, new SchemeRoot(rootPath));
        root = map.get(scheme);
      }
    }
    
    PathImpl path = null;
    
    if (root != null) {
      path = root.getRoot();
    }
    
    if (path != null) {
      return path;
    }
    else {
      return new NotFoundPath(this, scheme + ":");
    }
  }
617167
public function withScheme(string $scheme): URI
    {
        $result = clone $this;
        $result->scheme = $this->filterScheme($scheme);

        return $result;
    }
748794
protected function _prepareFilePath($path = null) {
		if (empty($path)) {
			return false;
		}

		if (DIRECTORY_SEPARATOR !== '\\') {
			return $path;
		}

		$path = str_replace('\\', '/', $path);

		return $path;
	}
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);
    }
253528
public static function toUrl(string $url, string $scheme = 'http://'): string
    {
        $http = preg_match('/^http[s]?:\/\//', $url);
        return (!$http ? $scheme : '') . $url;
    }
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);
    }
1367025
static function createUriString($scheme, $authority, $path, $query, $fragment) {
        $uri = '';
        if (!empty($scheme)) {
            $uri .= $scheme . ':';
        }
        $hierPart = '';
        if (!empty($authority)) {
            if (!empty($scheme)) {
                $hierPart .= '//';
            }
            $hierPart .= $authority;
        }
        if ($path != null) {
            // Add a leading slash if necessary.
            if ($hierPart && substr($path, 0, 1) !== '/') {
                $hierPart .= '/';
            }
            $hierPart .= $path;
        }
        $uri .= $hierPart;
        if ($query != null) {
            $uri .= '?' . $query;
        }
        if ($fragment != null) {
            $uri .= '#' . $fragment;
        }
        return $uri;
    }