public static function copyDirectory($source, $destination)
{
if (is_dir($source)) {
if (!file_exists($destination)) {
@mkdir($destination, 0777);
}
$directory = dir($source);
while (false !== ($readDirectory = $directory->read())) {
if ($readDirectory == '.' || $readDirectory == '..') {
continue;
}
$pathDir = $source . '/' . $readDirectory;
self::copyDirectory($pathDir, $destination . '/' . $readDirectory);
}
$directory->close();
} else {
$result = copy($source, $destination);
chmod($destination, self::FILE_PERMISSION);
return $result;
}
return true;
}