| Total Complexity | 4 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | trait AddsLines |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Add the given line after the last occurrence of the searched line |
||
| 13 | * |
||
| 14 | * @param string $search |
||
| 15 | * @param mixed $lineToAdd |
||
| 16 | * @return self |
||
| 17 | */ |
||
| 18 | public function addLineAfterLast(string $search, $lineToAdd): self |
||
| 19 | { |
||
| 20 | $newline = PHP_EOL; |
||
| 21 | $regex = "/([ \t]*).*{$search}.*{$newline}(?!.*{$search})/"; |
||
| 22 | |||
| 23 | return $this->addLineAfterRegex($regex, $lineToAdd); |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Add the given line after the provided regular expression |
||
| 28 | * |
||
| 29 | * @param string $regex |
||
| 30 | * @param mixed $lineToAdd |
||
| 31 | * @return self |
||
| 32 | */ |
||
| 33 | public function addLineAfterRegex(string $regex, $lineToAdd): self |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Add the given line after the last occurrence of the provided docblock comment |
||
| 49 | * |
||
| 50 | * @param string $search |
||
| 51 | * @param mixed $lineToAdd |
||
| 52 | * @return self |
||
| 53 | */ |
||
| 54 | public function addLineAfterLastDocblockComment(string $search, $lineToAdd): self |
||
| 60 | } |
||
| 61 | } |
||
| 62 |