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));
    }