src/XmlResourceRetriever/Utils.php
public static function relativePath(string $sourceFile, string $destinationFile): string
    {
        $source = static::simplifyPath($sourceFile);
        $destination = static::simplifyPath($destinationFile);
        if ($source[0] !== '' && $destination[0] === '') {
            return implode('/', $destination);
        }
        // remove the common path
        foreach ($source as $depth => $dir) {
            if (isset($destination[$depth])) {
                if ($dir === $destination[$depth]) {
                    unset($destination[$depth]);
                    unset($source[$depth]);
                } else {
                    break;
                }
            }
        }
        // add '..' to the beginning of the source as required by the count of from
        $fromCount = count($source);
        for ($i = 0; $i < $fromCount - 1; $i++) {
            array_unshift($destination, '..');
        }
        return implode('/', $destination);
    }
public static function relativePath(string $sourceFile, string $destinationFile): string
    {
        $source = static::simplifyPath($sourceFile);
        $destination = static::simplifyPath($destinationFile);
        if ($source[0] !== '' && $destination[0] === '') {
            return implode('/', $destination);
        }
        // remove the common path
        foreach ($source as $depth => $dir) {
            if (isset($destination[$depth])) {
                if ($dir === $destination[$depth]) {
                    unset($destination[$depth]);
                    unset($source[$depth]);
                } else {
                    break;
                }
            }
        }
        // add '..' to the beginning of the source as required by the count of from
        $fromCount = count($source);
        for ($i = 0; $i < $fromCount - 1; $i++) {
            array_unshift($destination, '..');
        }
        return implode('/', $destination);
    }
public static function relativePath ( string $ sourceFile , string $ destinationFile ) : string { $ source = static :: simplifyPath ( $ sourceFile ) ; $ destination = static :: simplifyPath ( $ destinationFile ) ; if ( $ source [ 0 ] !== '' && $ destination [ 0 ] === '' ) { return implode ( '/' , $ destination ) ; } // remove the common path foreach ( $ source as $ depth => $ dir ) { if ( isset ( $ destination [ $ depth ] ) ) { if ( $ dir === $ destination [ $ depth ] ) { unset ( $ destination [ $ depth ] ) ; unset ( $ source [ $ depth ] ) ; } else { break ; } } } // add '..' to the beginning of the source as required by the count of from $ fromCount = count ( $ source ) ; for ( $ i = 0 ; $ i < $ fromCount - 1 ; $ i ++ ) { array_unshift ( $ destination , '..' ) ; } return implode ( '/' , $ destination ) ; }
Return the relative path from one location to other

@param string $sourceFile
@param string $destinationFile
@return string
Return the relative path from one location to other