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