Conditions | 3 |
Paths | 3 |
Total Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
36 | 9 | public static function decamelize(string $input): string |
|
37 | { |
||
38 | 9 | preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); |
|
39 | 9 | $result = $matches[0]; |
|
40 | 9 | foreach ($result as &$match) { |
|
41 | 8 | $match = $match === strtoupper($match) ? strtolower($match) : lcfirst($match); |
|
42 | } |
||
43 | 9 | return implode('-', $result); |
|
44 | } |
||
45 | } |
||
46 |