Transforms URI into file path

@param string $uri
@return string
18639
public static function uriToPath(string $uri)
    {
        $fragments = parse_url($uri);
        if ($fragments === false || !isset($fragments['scheme']) || $fragments['scheme'] !== 'file') {
            throw new \InvalidArgumentException("Not a valid file URI: $uri");
        }
        $filepath = urldecode((string) $fragments['path']);
        if (strpos($filepath, ':') !== false) {
            if ($filepath[0] === '/') {
                $filepath = substr($filepath, 1);
            }
            $filepath = str_replace('/', '\\', $filepath);
        }
        return $filepath;
    }
708482
private static function route($uri) {
		$result = $uri;
		$routes = \Application::get('routes');
		if (empty($routes)) $routes = [];
		$extra_routes = \Object\ACL\Resources::getStatic('routes');
		if (!empty($extra_routes)) {
			$routes = array_merge($routes, $extra_routes);
		}
		if (!empty($routes)) {
			foreach ($routes as $v) {
				$regex = '#^' . $v['regex'] . '#i';
				if (preg_match($regex, $result, $values)) {
					$result = str_replace($v['regex'], $v['new'], $result);
				}
			}
		}
		return $result;
	}
243290
protected function prepareUrlForRequest($uri)
    {
        if (Str::startsWith($uri, '/')) {
            $uri = substr($uri, 1);
        }

        if (! Str::startsWith($uri, 'http')) {
            $uri = ($this->baseUrl ?? config('app.url')) . '/' . $uri;
        }

        return trim($uri, '/');
    }
1327003
public static function get_rest_path($uri=false) {
        if ( ! $uri ) $uri = $_SERVER['REQUEST_URI'];     // /tsugi/lti/some/cool/stuff
        $pos = strpos($uri,'?');
        if ( $pos > 0 ) $uri = substr($uri,0,$pos);
        if ( self::endsWith($uri, '/') ) {
            $uri = substr($uri, 0, strlen($uri)-1);
        }
        return $uri;
    }
823926
private function createUri($uri)
    {
        if ($this->hasBaseUri() && (stripos($uri, $baseUri = (string) $this->getBaseUri()) === false)) {
            return $baseUri.$uri;
        }

        return $uri;
    }
284519
protected function processUri($uri)
    {
        return preg_replace_callback('#\{([a-zA-Z0-9_,]*)\}#i', function ($matches) {
            return isset($this->tokens[$matches[1]]) ? $this->tokens[$matches[1]] : '';
        }, $uri);
    }
183346
public function uriToClassName(string $uri): string 
    {
        $string_parts = explode("-", $uri);
        $string = array_map('ucfirst', $string_parts);
        $string = implode("", $string) . "Controller"; 
        return preg_replace("/[^a-zA-Z0-9\-]/", "", $string);
    }
1354230
public static function removeLeadingSlash($uri)
    {
        $uri = self::filterUri($uri);
        $path = $uri->getPath();
        if ('' !== $path && '/' === $path[0]) {
            $path = substr($path, 1);
        }

        return self::normalizePath($uri, $path);
    }
1214990
private function toAbsoluteURI($uri)
    {
        list($pathBase, $scheme, $prePath) = $this->getPathInfo($this->configuration->getOriginalURL());

        // If this is already an absolute URI, return it.
        if (preg_match('/^[a-zA-Z][a-zA-Z0-9\+\-\.]*:/', $uri)) {
            return $uri;
        }

        // Scheme-rooted relative URI.
        if (substr($uri, 0, 2) === '//') {
            return $scheme . '://' . substr($uri, 2);
        }

        // Prepath-rooted relative URI.
        if (substr($uri, 0, 1) === '/') {
            return $prePath . $uri;
        }

        // Dotslash relative URI.
        if (strpos($uri, './') === 0) {
            return $pathBase . substr($uri, 2);
        }
        // Ignore hash URIs:
        if (substr($uri, 0, 1) === '#') {
            return $uri;
        }

        // Standard relative URI; add entire path. pathBase already includes a
        // trailing "/".
        return $pathBase . $uri;
    }
466565
protected function makeUriRelativeTo($uri, $root)
    {
        if (!$root) {
            return $uri;
        }

        if (is_array($uri)) {
            $uris = [];
            foreach ($uri as $u) {
                $uris[] = $this->makeUriRelativeTo($u, $root);
            }
            return $uris;
        }

        if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
            return $uri;
        }
        return rtrim($root, '/') . "/$uri";
    }
1186116
private static function parseURI($uri){
        //Remove protocol (for clarity).
        $uri = substr($uri, strlen('mmap://'));
        $parts = explode('?', $uri);

        $file_name_block_size = explode(':', $parts[0]);

        if(!isset($file_name_block_size[1])){
            throw new \Exception(sprintf('%s is not a valid uri', $uri));
        }

        $parsed = [];

        list($parsed['file_name'], $parsed['block_size']) = $file_name_block_size;

        if(isset($parts[1])){
            //Extra params
            parse_str($parts[1], $parsed['options']);
        } else {
            $parsed['options'] = [];
        }

        return $parsed;
    }
1202136
public function unlink($uri)
    {
        $this->uri = $uri;

        return $this->invoke($this->getFilesystem(), 'delete', [$this->getTarget()], 'unlink');
    }
920000
public static function parse(string $uri): URI
    {
        if ($uri == '') {
            return new static();
        }

        $parts = parse_url($uri);
        if ($parts === false) {
            throw new \InvalidArgumentException(sprintf('Cannot parse malformed uri "%s".', $uri));
        }

        if (!isset($parts['scheme'])) {
            throw new \InvalidArgumentException(sprintf('Missing scheme in uri "%s".', $uri));
        }

        if (count($parts) == 1 && isset($parts['scheme'])) {
            throw new \InvalidArgumentException(sprintf('Missing hierarchical segment in uri "%s".', $uri));
        }

        $defaults = [
            'scheme' => '',
            'host' => '',
            'user' => '',
            'pass' => '',
            'port' => null,
            'path' => '',
            'query' => '',
            'fragment' => '',
        ];

        $parts = array_merge($defaults, $parts);

        return new static(
            $parts['scheme'],
            $parts['host'],
            $parts['path'],
            $parts['query'],
            $parts['fragment'],
            $parts['user'],
            $parts['pass'],
            $parts['port']
        );
    }
666785
public function get(string $uri): Description
    {
        if (!$uri) {
            throw new \InvalidArgumentException("No document URI provided");
        }
        if ($this->basePath) {
            $uri = "$this->basePath/$uri";
        }
        if (!isset($this->specifications[$uri])) {
            $this->specifications[$uri] = $this->load($uri);
        }

        return $this->specifications[$uri];
    }
1217686
public static function getAbsoluteUri(string $uri = null) : string
    {
        $uri = new self($uri);

        return $uri->get(false);
    }
1058833
public function baseUrl($uri = '')
    {
        return sprintf(
            "%s://%s%s%s%s",
            isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
            $_SERVER['SERVER_NAME'],
            ($_SERVER['SERVER_PORT'] == 80) ?: ':' . $_SERVER['SERVER_PORT'],
            $_SERVER['REQUEST_URI'],
            ltrim($uri, '/')
        );
    }
679294
public function asset($uri = null)
    {
        if (empty($uri)) {
            // Allow empty
        } elseif (substr($uri, 0, 7) == "http://"
            || substr($uri, 0, 8) == "https://"
            || substr($uri, 0, 2) == "//"
        ) {
            // Fully qualified, just leave as is.
            return rtrim($uri, '/');
        } elseif ($uri[0] == '/') {
            // Absolute url, prepend with staticSiteUrl
            return rtrim($this->staticSiteUrl . rtrim($uri, '/'), '/');
        }

        $baseUrl = isset($this->staticBaseUrl)
            ? $this->staticBaseUrl
            : $this->baseUrl;

        return empty($uri)
            ? $baseUrl
            : $baseUrl . '/' . $uri;
    }