| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 18 | public static function decamelize(string $input): string |
|
| 17 | { |
||
| 18 | // It's for global section |
||
| 19 | 18 | if (in_array($input, ['listenAddr', 'listen-addr'])) { |
|
| 20 | 7 | return 'listen-addr'; |
|
| 21 | } |
||
| 22 | |||
| 23 | 17 | preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); |
|
| 24 | 17 | $result = $matches[0]; |
|
| 25 | 17 | foreach ($result as &$match) { |
|
| 26 | 17 | $match = $match === strtoupper($match) ? strtolower($match) : lcfirst($match); |
|
| 27 | } |
||
| 28 | |||
| 29 | 17 | return implode(' ', $result); |
|
| 30 | } |
||
| 31 | } |
||
| 32 |