| Conditions | 5 |
| Paths | 7 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | public function save(array $answers) |
||
| 33 | { |
||
| 34 | $path = $this->directory . DIRECTORY_SEPARATOR . $this->file; |
||
| 35 | |||
| 36 | if (!file_exists($path)) { |
||
| 37 | if (!is_writable($this->directory)) { |
||
| 38 | throw new WritableException(sprintf('The env file is not present and the directory `%s` is not writeable!', $this->directory)); |
||
| 39 | } |
||
| 40 | |||
| 41 | touch($path); |
||
| 42 | } |
||
| 43 | |||
| 44 | if (!is_writable($path)) { |
||
| 45 | throw new WritableException(sprintf('The env file `%s` is not writeable!', $path)); |
||
| 46 | } |
||
| 47 | |||
| 48 | $text = ''; |
||
| 49 | foreach ($answers as $key => $value) { |
||
| 50 | $text .= sprintf("%s=%s\n", $key, $value); |
||
| 51 | } |
||
| 52 | |||
| 53 | file_put_contents($path, $text); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |