| Conditions | 6 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 6.0493 |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 19 | 3 | public function append($resource, $key, $value) |
|
| 20 | { |
||
| 21 | 3 | $lastChar = substr(file_get_contents($resource), -1); |
|
| 22 | |||
| 23 | 3 | $prefix = ""; |
|
| 24 | 3 | if ($lastChar != "\n" && $lastChar != "\r" && strlen($lastChar) == 1) { |
|
| 25 | 3 | $prefix = PHP_EOL; |
|
| 26 | } |
||
| 27 | |||
| 28 | 3 | if (strpos($value, ' ') !== false && strpos($value, '"') === false) { |
|
| 29 | $value = '"' . $value . '"'; |
||
| 30 | } |
||
| 31 | |||
| 32 | 3 | file_put_contents($resource, $prefix . $key . '=' . $value, FILE_APPEND); |
|
| 33 | 3 | } |
|
| 34 | } |
||
| 35 |