From d8fa7d01bfb79a46d2bcdc757ce4641e5fb113ef Mon Sep 17 00:00:00 2001 From: Avior Date: Thu, 7 Mar 2019 12:56:11 +0100 Subject: [PATCH] push --- assets/php/Functions.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/assets/php/Functions.php b/assets/php/Functions.php index f0c0b7c..b6e6c5b 100644 --- a/assets/php/Functions.php +++ b/assets/php/Functions.php @@ -75,20 +75,19 @@ class Functions { } public static function deleteDir($dirPath) { - if (! is_dir($dirPath)) { - throw new InvalidArgumentException("$dirPath must be a directory"); - } - if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { - $dirPath .= '/'; - } - $files = glob($dirPath . '*', GLOB_MARK); - foreach ($files as $file) { - if (is_dir($file)) { - self::deleteDir($file); - } else { - unlink($file); + if (is_dir($dirPath)) { + if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { + $dirPath .= '/'; } + $files = glob($dirPath . '*', GLOB_MARK); + foreach ($files as $file) { + if (is_dir($file)) { + self::deleteDir($file); + } else { + unlink($file); + } + } + rmdir($dirPath); } - rmdir($dirPath); } }