| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public static function addLine(string $file, string $line): bool |
||
| 18 | { |
||
| 19 | if (!file_exists($file)) { |
||
| 20 | return false; |
||
| 21 | } |
||
| 22 | |||
| 23 | $handle = fopen($file, 'r+'); |
||
| 24 | |||
| 25 | while (($currentLine = fgets($handle)) !== false) { |
||
|
|
|||
| 26 | if (trim($currentLine) == $line) { |
||
| 27 | return false; |
||
| 28 | } |
||
| 29 | } |
||
| 30 | |||
| 31 | fwrite($handle, $line.PHP_EOL); |
||
| 32 | |||
| 33 | fclose($handle); |
||
| 34 | |||
| 35 | return true; |
||
| 36 | } |
||
| 94 |