Conditions | 7 |
Paths | 4 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | public function write(string $path, string $content): void |
||
12 | { |
||
13 | if (file_exists($path) && $content === file_get_contents($path)) { |
||
14 | return; |
||
15 | } |
||
16 | $dirname = dirname($path); |
||
17 | if (!file_exists($dirname) && !mkdir($dirname, 0777, true) && !is_dir($dirname)) { |
||
18 | throw new FailedWriteException(sprintf('Directory "%s" was not created', $dirname)); |
||
19 | } |
||
20 | if (false === file_put_contents($path, $content)) { |
||
21 | throw new FailedWriteException("Failed write file $path"); |
||
22 | } |
||
25 |