| Conditions | 5 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 33 | protected function writeFile(string $targetPath, bool $overwrite, string $data) |
||
| 34 | { |
||
| 35 | if (file_exists($targetPath) && !$overwrite) { |
||
| 36 | $this->comment("File $targetPath already exists, not overwriting."); |
||
|
|
|||
| 37 | return; |
||
| 38 | } |
||
| 39 | |||
| 40 | $dir = dirname($targetPath); |
||
| 41 | if (!is_dir($dir)) { |
||
| 42 | \Safe\mkdir($dir, 0777, true); |
||
| 43 | } |
||
| 44 | |||
| 45 | $ret = \Safe\file_put_contents($targetPath, $data); |
||
| 46 | if (!$ret) { |
||
| 47 | $this->error("Cannot write to $targetPath"); |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | $this->line("Wrote $targetPath"); |
||
| 51 | } |
||
| 53 |