Conditions | 5 |
Paths | 2 |
Total Lines | 33 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
34 | 1 | public static function remove($path, $recursive = false) |
|
35 | { |
||
36 | 1 | $path = \rtrim($path, '/') . '/'; |
|
37 | |||
38 | 1 | if ($recursive) |
|
39 | { |
||
40 | |||
41 | 1 | $storage = \array_merge( |
|
42 | 1 | \glob($path . '*'), |
|
|
|||
43 | 1 | \glob($path . '.*') |
|
44 | ); |
||
45 | |||
46 | 1 | foreach ($storage as $item) |
|
47 | { |
||
48 | |||
49 | 1 | if (in_array(basename($item), ['.', '..'], true)) |
|
50 | { |
||
51 | 1 | continue; |
|
52 | } |
||
53 | |||
54 | 1 | if (static::isDir($item)) |
|
55 | { |
||
56 | 1 | static::remove($item, $recursive); |
|
57 | 1 | continue; |
|
58 | } |
||
59 | |||
60 | 1 | File::remove($item); |
|
61 | |||
62 | } |
||
63 | |||
64 | } |
||
65 | |||
66 | 1 | return rmdir($path); |
|
67 | } |
||
70 |