Total Complexity | 11 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
6 | class FileSystem |
||
7 | { |
||
8 | public static function mkdir(string $dir, int $mode = 0777): void |
||
9 | { |
||
10 | if (is_dir($dir)) { |
||
11 | return; |
||
12 | } |
||
13 | |||
14 | if (true !== @mkdir($dir, $mode, true)) { |
||
15 | $error = error_get_last(); |
||
16 | if (!is_dir($dir)) { |
||
17 | // The directory was not created by a concurrent process. |
||
18 | // Let's throw an exception with a developer friendly error message if we have one |
||
19 | if ($error !== null) { |
||
20 | throw IoException::cannotCreateDirectory($dir, $error['message']); |
||
21 | } |
||
22 | throw IoException::cannotCreateDirectory($dir, 'unknown error'); |
||
23 | } |
||
24 | } |
||
25 | } |
||
26 | |||
27 | public static function rmdir(string $dir): void |
||
41 | } |
||
42 | } |
||
44 |