Total Complexity | 10 |
Total Lines | 80 |
Duplicated Lines | 0 % |
Coverage | 52.5% |
Changes | 0 |
1 | <?php |
||
9 | class Helper |
||
10 | { |
||
11 | /** |
||
12 | * @param $cif |
||
13 | * @return bool |
||
14 | */ |
||
15 | 2 | public static function validateCif($cif) |
|
50 | } |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Convert a string to camelCase. Strings already in camelCase will not be harmed. |
||
55 | * |
||
56 | * @param string $str The input string |
||
57 | * @return string camelCased output string |
||
58 | */ |
||
59 | public static function camelCase($str) |
||
60 | { |
||
61 | $str = self::convertToLowercase($str); |
||
62 | return preg_replace_callback( |
||
63 | '/_([a-z])/', |
||
64 | function ($match) { |
||
65 | return strtoupper($match[1]); |
||
66 | }, |
||
67 | $str |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Convert strings with underscores to be all lowercase before camelCase is preformed. |
||
73 | * |
||
74 | * @param string $str The input string |
||
75 | * @return string The output string |
||
76 | */ |
||
77 | protected static function convertToLowercase($str) |
||
89 | } |
||
90 | } |
||
91 |