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