src/XmlResourceRetriever/Utils.php
public static function simplifyPath(string $path): array
    {
        $parts = explode('/', str_replace('//', '/./', $path));
        $count = count($parts);
        for ($i = 0; $i < $count; $i = $i + 1) {
            // is .. and previous is not ..
            if ($i > 0 && '..' === $parts[$i] && '..' !== $parts[$i - 1]) {
                unset($parts[$i - 1]);
                unset($parts[$i]);
                return static::simplifyPath(implode('/', $parts));
            }
            // is inner '.'
            if ('.' == $parts[$i]) {
                unset($parts[$i]);
                return static::simplifyPath(implode('/', $parts));
            }
        }
        return array_values($parts);
    }
public static function simplifyPath(string $path): array
    {
        $parts = explode('/', str_replace('//', '/./', $path));
        $count = count($parts);
        for ($i = 0; $i < $count; $i = $i + 1) {
            // is .. and previous is not ..
            if ($i > 0 && '..' === $parts[$i] && '..' !== $parts[$i - 1]) {
                unset($parts[$i - 1]);
                unset($parts[$i]);
                return static::simplifyPath(implode('/', $parts));
            }
            // is inner '.'
            if ('.' == $parts[$i]) {
                unset($parts[$i]);
                return static::simplifyPath(implode('/', $parts));
            }
        }
        return array_values($parts);
    }
public static function simplifyPath ( string $ path ) : array { $ parts = explode ( '/' , str_replace ( '//' , '/./' , $ path ) ) ; $ count = count ( $ parts ) ; for ( $ i = 0 ; $ i < $ count ; $ i = $ i + 1 ) { // is .. and previous is not .. if ( $ i > 0 && '..' === $ parts [ $ i ] && '..' !== $ parts [ $ i - 1 ] ) { unset ( $ parts [ $ i - 1 ] ) ; unset ( $ parts [ $ i ] ) ; return static :: simplifyPath ( implode ( '/' , $ parts ) ) ; } // is inner '.' if ( '.' == $ parts [ $ i ] ) { unset ( $ parts [ $ i ] ) ; return static :: simplifyPath ( implode ( '/' , $ parts ) ) ; } } return array_values ( $ parts ) ; }
Simplify a path and return its parts as an array

@param string $path
@return array
Simplify a path and return its parts as an array