public static function removeFolder($dirPath)
{
$files = array_diff(scandir($dirPath), array('.', '..'));
foreach ($files as $file) {
if (is_dir("{$dirPath}/{$file}")) {
self::removeFolder("{$dirPath}/{$file}");
} else {
if (!unlink("{$dirPath}/{$file}")) {
throw new Exception\RuntimeException("Falha! sem permissão de exclusão do arquivo {$dirPath}/{$file}");
}
}
}
if (!rmdir($dirPath)) {
$msg = "Falha! sem permissão de exclusão do diretório {$dirPath}";
throw new Exception\RuntimeException($msg);
}
return true;
}