src/CodeGeneration/PathHelper.php
public function resolvePath(string $relativePath): string
    {
        $path     = [];
        $absolute = (strpos($relativePath, '/') === 0);
        foreach (explode('/', $relativePath) as $part) {
            // ignore parts that have no value
            if (empty($part) || $part === '.') {
                continue;
            }

            if ($part !== '..') {
                $path[] = $part;
                continue;
            }
            if (count($path) > 0) {
                // going back up? sure
                array_pop($path);
                continue;
            }
            throw new \RuntimeException('Relative path resolves above root path.');
        }

        $return = implode('/', $path);
        if ($absolute) {
            $return = "/$return";
        }

        return $return;
    }
public function resolvePath(string $relativePath): string
    {
        $path     = [];
        $absolute = (strpos($relativePath, '/') === 0);
        foreach (explode('/', $relativePath) as $part) {
            // ignore parts that have no value
            if (empty($part) || $part === '.') {
                continue;
            }

            if ($part !== '..') {
                $path[] = $part;
                continue;
            }
            if (count($path) > 0) {
                // going back up? sure
                array_pop($path);
                continue;
            }
            throw new \RuntimeException('Relative path resolves above root path.');
        }

        $return = implode('/', $path);
        if ($absolute) {
            $return = "/$return";
        }

        return $return;
    }
public function resolvePath ( string $ relativePath ) : string { $ path = [ ] ; $ absolute = ( strpos ( $ relativePath , '/' ) === 0 ) ; foreach ( explode ( '/' , $ relativePath ) as $ part ) { // ignore parts that have no value if ( empty ( $ part ) || $ part === '.' ) { continue ; } if ( $ part !== '..' ) { $ path [ ] = $ part ; continue ; } if ( count ( $ path ) > 0 ) { // going back up? sure array_pop ( $ path ) ; continue ; } throw new \ RuntimeException ( 'Relative path resolves above root path.' ) ; } $ return = implode ( '/' , $ path ) ; if ( $ absolute ) { $ return = "/$return" ; } return $ return ; }
Take a potentially non existent path and resolve the relativeness into a normal path

@param string $relativePath

@return string
@throws \RuntimeException
Take a potentially non existent path and resolve the relativeness into a normal path