Get entity internal path from internal URI

@param string $uri
Must match one of the supported schemes

@throws \InvalidArgumentException
779286
public function getEntityPathFromURI($uri)
    {
        if ($parts = $this->decomposeURI($uri)) {
            return $this->getEntityPath($parts['type'], $parts['id']);
        }

        throw new \InvalidArgumentException(sprintf("%s: invalid entity URI scheme or malformed URI", $uri));
    }
1003181
public function internalRedirect($uri)
    {
        if (is_string($uri)) {

            // make a new URI instance, then make a new request
            $uri = $this->request->getUri()->withPath($uri);
            return $this->request->withUri($uri);

        } elseif ($uri instanceof UriInterface) {

            // get a new request with the specified URI instance
            return $this->request->withUri($uri);

        } else {

            // bad $uri value
            throw new InvalidArgumentException(
                'URI should be a string or instance of Psr\Http\Message\UriInterface'
            );

        }
    }
1009622
protected function _normalizedUrl($uri)
    {
        $out = $uri->getScheme() . '://';
        $out .= strtolower($uri->getHost());
        $out .= $uri->getPath();

        return $out;
    }
334480
private function validateUri(string $uri): void
    {
        if (filter_var($uri, FILTER_VALIDATE_URL) === false) {
            throw new InvalidArgumentException(sprintf('%s is not a valid uri', $uri));
        }
    }
1021258
public function resolveRelativeUri(string $uri): string
    {
        $parts = parse_url($uri);
        if (isset($parts['scheme'])) {
            // absolute URL
            return $uri;
        }

        $baseUri = $this->getUri();
        if (strncmp($baseUri, 'file://', 7) === 0) {
            if (isset($parts['path'][0]) && $parts['path'][0] === '/') {
                // absolute path
                return 'file://' . $parts['path'];
            }
            if (isset($parts['path'])) {
                // relative path
                return dirname($baseUri) . '/' . $parts['path'];
            }

            throw new UnresolvableReferenceException("Invalid URI: '$uri'");
        }

        $baseParts = parse_url($baseUri);
        $absoluteUri = implode('', [
            $baseParts['scheme'],
            '://',
            isset($baseParts['username']) ? $baseParts['username'] . (
                isset($baseParts['password']) ? ':' . $baseParts['password'] : ''
            ) . '@' : '',
            $baseParts['host'] ?? '',
            isset($baseParts['port']) ? ':' . $baseParts['port'] : '',
        ]);
        if (isset($parts['path'][0]) && $parts['path'][0] === '/') {
            $absoluteUri .= $parts['path'];
        } elseif (isset($parts['path'])) {
            $absoluteUri .= rtrim(dirname($baseParts['path'] ?? ''), '/') . '/' . $parts['path'];
        }
        return $absoluteUri
            . (isset($parts['query']) ? '?' . $parts['query'] : '')
            . (isset($parts['fragment']) ? '#' . $parts['fragment'] : '');
    }
314671
private function getResourceParam($uri)
    {
        $resource = $this->injector->getInstance(ResourceInterface::class);
        $resourceResult = $resource->get->uri($uri)->eager->request();
        $fragment = parse_url($uri, PHP_URL_FRAGMENT);

        return $resourceResult[$fragment];
    }
387852
public static function datapathToAscii($uri)
    {
        return $uri->withPath((string) (new DataPath(self::filterUri($uri)->getPath()))->toAscii());
    }
65395
protected function fromString($uri)
    {
        if (! is_string($uri)) {
            throw new InvalidArgumentException(sprintf(
                '"%s()" expects string; "%s" received.',
                __METHOD__,
                is_object($uri) ? get_class($uri) : gettype($uri)
            ));
        }

        $this
            ->setUserInfo(
                parse_url($uri, PHP_URL_USER),
                parse_url($uri, PHP_URL_PASS)
            )
            ->setScheme(parse_url($uri,   PHP_URL_SCHEME))
            ->setHost(parse_url($uri,     PHP_URL_HOST))
            ->setPath(parse_url($uri,     PHP_URL_PATH))
            ->setQuery(parse_url($uri,    PHP_URL_QUERY))
            ->setFragment(parse_url($uri, PHP_URL_FRAGMENT));

        if ($port = parse_url($uri, PHP_URL_PORT)) {
            $this->setPort($port);
        }

        return $this;
    }
1348992
static public function getRoute($uri = null)
    {
        $routes = self::$instance->routes;
        if($uri === null) {
            foreach($routes as $i => $route) {
                $routes[$i] = \array_diff_key($routes[$i], [3 => "xy", 4 => "xy", 5 => "xy", 6 => "xy", 7 => "xy", 8 => "xy"]);
                if( !is_string($routes[$i][2]) && is_object($routes[$i][2]) && is_callable($routes[$i][2]) && $routes[$i][2] instanceof \Closure) {
                    $routes[$i][2] = "Closure";
                }
            }
            return $routes;
        }
        else {
            foreach($routes as $i => $route) {
                if($route[1] === "/".ltrim($uri,"/")) {
                    return $route;
                }
            }
        }
    }
1071288
public function createGeneric($uri)
    {
        if (!is_string($uri)) {
            throw new InvalidArgumentException('URI must be a string.');
        }

        $schemeClass = $this->defaultClass();

        return new $schemeClass($uri);
    }
1087473
public function load(UriInterface $uri)
    {
        if (!$uri instanceof FileUriInterface) {
            throw new InvalidUriTypeException(
                $uri,
                'Eloquent\Schemer\Uri\FileUriInterface'
            );
        }

        $path = $this->pathFromUri($uri);

        try {
            $data = $this->isolator->file_get_contents($path);
        } catch (ErrorException $e) {
            throw new LoadException($uri, $e);
        }

        return new Content($data, $this->extensionMap()->getByPath($path));
    }
1058112
public function getUri($uri) {
        $curieSeperator = ':';

        if (preg_match('/http(s*)\:\/\//', $uri) == false) {
            if (strpos($uri, $curieSeperator) !== false) {
                list($prefix, $action) = explode($curieSeperator, $uri);
                
                if(isset($this->WAMP->prefixes[$prefix]) === true){
                  return $this->WAMP->prefixes[$prefix] . '#' . $action;
                }
            }
        }

        return $uri;
    }
1097748
public function entity($url, EntityInterface $entity, $override = false)
    {
        if (!($path = parse_url($url, PHP_URL_PATH))) {
            throw new \InvalidArgumentException('It is invalid URL: '.$url);
        }
        $entity->setFilename(pathinfo($path, PATHINFO_BASENAME));
        $target = $this->root.$entity->getDownloadPath().'/'.$entity->getFilename();

        if ($entity instanceof ImageInterface) {
            return $this->image($url, $target, $override);
        } else {
            return $this->download($url, $target, $override);
        }
    }
1109496
protected function getClassToExport($uri)
    {
        $resource = $this->getResource($uri);

        if ($resource->isClass()) {
            $classToExport = $this->getClass($uri);
        } else {
            $classToExport = reset($resource->getTypes());
        }

        return $classToExport;
    }
1124719
private function parseUri($uri)
    {
        $parts = parse_url($uri);

        if (false === $parts) {
            throw new \InvalidArgumentException(
                'The source URI string appears to be malformed'
            );
        }

        $this->scheme    = isset($parts['scheme'])   ? $this->filterScheme($parts['scheme']) : '';
        $this->userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->host      = isset($parts['host'])     ? $parts['host']     : '';
        $this->port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->path      = isset($parts['path'])     ? $this->filterPath($parts['path']) : '';
        $this->query     = isset($parts['query'])    ? $this->filterQuery($parts['query']) : '';
        $this->fragment  = isset($parts['fragment']) ? $this->filterFragment($parts['fragment']) : '';

        if (isset($parts['pass'])) {
            $this->userInfo .= ':' . $parts['pass'];
        }
    }
1048625
private function parse($uri)
    {
        $this->parsedUri = parse_url($uri);

        if (false === strstr($this->parsedUri['path'], $this->config->getRootEndpoint())) {
            throw RestException::invalidEndpoint($this->parsedUri['path']);
        }

        $this->adjustRootEndpoint($this->parsedUri['path']);

        $this->parsedUri['path'] = str_replace($this->config->getRootEndpoint(), '', $this->parsedUri['path']);
        $this->parsePath($this->parsedUri['path']);

        $this->parsedUri['query'] = isset($this->parsedUri['query']) ? $this->parsedUri['query'] : '';
        $this->parseQueryString($this->parsedUri['query']);

        return $this;
    }
131270
protected function pathFromUri(HttpUriInterface $uri)
    {
        $path = $uri->getPath();
        if (null === $path) {
            $path = '';
        }

        return $path;
    }