| Conditions | 5 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | } |
||
| 44 |