Jarves\Filesystem\Filesystem::normalizePath PHP Méthode

normalizePath() public méthode

Also removes '..' and replaces '//' => '/' This is needed because the file layer gets the relative path under his own root. Forces a / at the beginning, removes the trailing / if exists.
public normalizePath ( string | array $path ) : string
$path string | array
Résultat string
    public function normalizePath($path)
    {
        if (is_array($path)) {
            $result = [];
            foreach ($path as $p) {
                $result[] = $this->normalizePath($p);
            }
            return $result;
        } else {
            if ('/' !== $path[0]) {
                $path = '/' . $path;
            }
            if ('/' === substr($path, -1)) {
                $path = substr($path, 0, -1);
            }
            $fs = $this->getAdapter($path);
            $path = substr($path, strlen($fs->getMountPath()));
            if ('/' !== $path[0]) {
                $path = '/' . $path;
            }
            $path = str_replace('..', '', $path);
            $path = str_replace('//', '/', $path);
            return $path;
        }
    }