/**
* Remove all references to root directory path and the system tmp path from a message
*
* @param string $message The message to be cleaned
* @param string $rootDirectory Optional root directory, defaults to JPATH_ROOT
*
* @return string
*
* @since 3.10.7
*/
public static function removeRoot($message, $rootDirectory = null)
{
if (empty($rootDirectory)) {
$rootDirectory = JPATH_ROOT;
}
$makePattern = static function ($dir) {
return '~' . str_replace('~', '\\~', preg_replace('~[/\\\\]+~', '[/\\\\\\\\]+', $dir)) . '~';
};
$replacements = [$makePattern(static::clean($rootDirectory)) => '[ROOT]', $makePattern(sys_get_temp_dir()) => '[TMP]'];
return preg_replace(array_keys($replacements), array_values($replacements), $message);
}