src/DataHandling.php
public static function makePathRelative($path, $rootDirectory)
    {
        $rootDirectory = self::formatDirectory($rootDirectory);
        $path = self::formatPath($path);

        if (!self::startsWith(self::formatDirectory($path), $rootDirectory)) {
            throw new DataHandlingException("Path is not part of the given root directory.");
        }

        return substr_replace($path, "", 0, strlen($rootDirectory));
    }
public static function makePathRelative($path, $rootDirectory)
    {
        $rootDirectory = self::formatDirectory($rootDirectory);
        $path = self::formatPath($path);

        if (!self::startsWith(self::formatDirectory($path), $rootDirectory)) {
            throw new DataHandlingException("Path is not part of the given root directory.");
        }

        return substr_replace($path, "", 0, strlen($rootDirectory));
    }
public static function makePathRelative ( $ path , $ rootDirectory ) { $ rootDirectory = self :: formatDirectory ( $ rootDirectory ) ; $ path = self :: formatPath ( $ path ) ; if ( ! self :: startsWith ( self :: formatDirectory ( $ path ) , $ rootDirectory ) ) { throw new DataHandlingException ( "Path is not part of the given root directory." ) ; } return substr_replace ( $ path , "" , 0 , strlen ( $ rootDirectory ) ) ; }
Makes given path relative to the given root directory.

@param string $path
@param string $rootDirectory
@return string
@throws DataHandlingException Thrown when the path is not part of the given root directory.
Makes given path relative to the given root directory .