| Conditions | 1 |
| Paths | 1 |
| Total Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 42 | public static function toSnakeCase(string $source, string $separator = '_'): string |
||
| 43 | { |
||
| 44 | // If the string is pascal/camel case |
||
| 45 | $modified = str_replace(' ', ' ', preg_replace('/[A-Z]+/', ' $0', $source)); |
||
| 46 | $lowercase = mb_strtolower(trim($modified)); |
||
| 47 | |||
| 48 | return str_replace(' ', $separator, $lowercase); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |