abstract class DirHelper { public static function cpdir(string $source, string $target): void { $src_dir = opendir($source); mkdir($target); while (($file = readdir($src_dir))) { if (!in_array($file, ['.', '..'])) { if (is_dir($source.DIRECTORY_SEPARATOR.$file)) { self::cpdir($source.DIRECTORY_SEPARATOR.$file, $target.DIRECTORY_SEPARATOR.$file); } else { copy($source.DIRECTORY_SEPARATOR.$file,$target.DIRECTORY_SEPARATOR.$file); } } } closedir($src_dir); } }