aboutsummaryrefslogtreecommitdiff
path: root/src/phorkie/Tools.php
blob: c6e4db5093007ed0c17292a6d53efc9dc058696d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace phorkie;


class Tools
{
    public static function recursiveDelete($path)
    {
        if (!is_dir($path) || is_link($path)) {
            return unlink($path);
        }
        foreach (scandir($path) as $file) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            $filepath = $path . DIRECTORY_SEPARATOR . $file;
            if (!static::recursiveDelete($filepath)) {
                return false;
            };
        }
        return rmdir($path);
    }

}

?>