1 | <?php |
||
9 | final class Unlink |
||
10 | { |
||
11 | /** |
||
12 | * @var array |
||
13 | */ |
||
14 | private static $unlinkedPath = []; |
||
15 | |||
16 | 11 | public function __invoke(string $path) |
|
17 | { |
||
18 | 11 | if (file_exists($path . '/.do_not_clear')) { |
|
19 | 11 | return; |
|
20 | } |
||
21 | 11 | foreach (\glob(\rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*') as $file) { |
|
22 | 11 | \is_dir($file) ? $this->__invoke($file) : \unlink($file); |
|
23 | 11 | @\rmdir($file); |
|
|
|||
24 | } |
||
25 | 11 | } |
|
26 | |||
27 | 25 | public function once(string $path) : bool |
|
37 | } |
||
38 |
If you suppress an error, we recommend checking for the error condition explicitly: