Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
55 | private function addOrUpdateIncrement(string $string): string |
||
56 | { |
||
57 | $pattern = '/-(\d+$)/'; |
||
58 | $matches = []; |
||
59 | |||
60 | if (! preg_match($pattern, $string, $matches)) { |
||
61 | return $string.'-1'; |
||
62 | } |
||
63 | |||
64 | $increment = $matches[1] + 1; |
||
65 | |||
66 | return preg_replace($pattern, "-{$increment}", $string); |
||
67 | } |
||
68 | } |
||
69 |