Conditions | 6 |
Paths | 5 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public static function delete($path) |
||
20 | { |
||
21 | if (!SapphireTest::is_running_test() || !file_exists($path)) { |
||
22 | return false; |
||
23 | } |
||
24 | |||
25 | $path = BASE_PATH . DIRECTORY_SEPARATOR . $path; |
||
26 | if (is_dir($path)) { |
||
27 | $files = new RecursiveIteratorIterator( |
||
28 | new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), |
||
29 | RecursiveIteratorIterator::CHILD_FIRST |
||
30 | ); |
||
31 | |||
32 | foreach ($files as $fileinfo) { |
||
33 | $action = $fileinfo->isDir() ? 'rmdir' : 'unlink'; |
||
34 | $action($fileinfo->getRealPath()); |
||
35 | } |
||
36 | |||
37 | rmdir($path); |
||
38 | } else { |
||
39 | unlink($path); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 |