Conditions | 4 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | 1 | public static function convertToSnakeCase($string) |
|
17 | { |
||
18 | 1 | $result = ''; |
|
19 | 1 | $len = strlen($string); |
|
20 | |||
21 | 1 | for ($i = 0; $i < $len; ++$i) { |
|
22 | 1 | if ($i !== 0 && ctype_upper($string[$i])) { |
|
23 | 1 | $result .= '_'.strtolower($string[$i]); |
|
24 | 1 | } else { |
|
25 | 1 | $result .= strtolower($string[$i]); |
|
26 | } |
||
27 | 1 | } |
|
28 | |||
29 | 1 | return $result; |
|
30 | } |
||
31 | } |
||
32 |