| Conditions | 2 |
| Paths | 1 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public function addLineAfterRegex(string $regex, $lineToAdd): self |
||
| 34 | { |
||
| 35 | $callback = function (array $matches) use ($lineToAdd) { |
||
| 36 | $value = is_callable($lineToAdd) ? $lineToAdd($matches) : $lineToAdd; |
||
| 37 | return $matches[0] . $matches[1] . $value . PHP_EOL; |
||
| 38 | }; |
||
| 39 | |||
| 40 | $content = preg_replace_callback($regex, $callback, file_get_contents($this->getPath())); |
||
|
|
|||
| 41 | |||
| 42 | file_put_contents($this->getPath(), $content); |
||
| 43 | |||
| 44 | return $this; |
||
| 45 | } |
||
| 62 |