| Conditions | 5 |
| Paths | 4 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | public function __invoke(string $filename, string $content) : void |
||
| 14 | { |
||
| 15 | $dir = dirname($filename); |
||
| 16 | ! is_dir($dir) && mkdir($dir, 0777, true); |
||
| 17 | $tmpFile = tempnam(dirname($filename), 'swap'); |
||
| 18 | if (is_string($tmpFile) && file_put_contents($tmpFile, $content) && @rename($tmpFile, $filename)) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | @unlink((string) $tmpFile); |
||
|
|
|||
| 22 | |||
| 23 | throw new FileNotWritable($filename); |
||
| 24 | } |
||
| 25 | } |
||
| 26 |
If you suppress an error, we recommend checking for the error condition explicitly: