read())) { if ($entry != '.' && $entry != '..') { $this->copy_folder("$d1/$entry", "$d2/$entry"); } } $d->close(); } else { copy($d1, $d2); } } public function recursiveRemoveDir($dir): void { $includes = new FilesystemIterator($dir); foreach ($includes as $include) { if(is_dir($include) && !is_link($include)) { $this->recursiveRemoveDir($include); } else { unlink($include); } } rmdir($dir); } }