protected function removeTargetFiles($directory)
{
$file_paths = scandir($directory);
foreach ($file_paths as $file_path) {
foreach ($this->exclude_folders as $exclude) {
if ($exclude === $file_path || strpos($file_path, $exclude) > 0) {
$file_path = '';
}
}
if ($file_path === '' || $file_path === '.' || $file_path === '..') {
} else {
if (filetype($directory . '/' . $file_path) === 'dir') {
$this->removeTargetFiles($directory . '/' . $file_path);
} else {
unlink($directory . '/' . $file_path);
}
}
}
if ($directory === $this->base_path . $this->target_path) {
} else {
rmdir($directory);
}
return $this;
}