| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 3 | function export_env($from='.env', $to='.env.example') |
||
| 4 | { |
||
| 5 | 7 | if(!file_exists($from)) { |
|
| 6 | 2 | throw new \Exception("File [$from] not found"); |
|
| 7 | } |
||
| 8 | 5 | $files = file($from); |
|
| 9 | 5 | $newFile = $to; |
|
| 10 | 5 | file_put_contents($newFile, ''); |
|
| 11 | 5 | foreach ($files as $file) { |
|
| 12 | 5 | $key = explode("=", $file)[0]; |
|
| 13 | 5 | if (empty(trim($key))) continue; |
|
| 14 | 5 | file_put_contents($newFile, "$key=" . PHP_EOL, FILE_APPEND); |
|
| 15 | } |
||
| 16 | 5 | return true; |
|
| 17 | } |
||
| 18 |