biscolab /
updown-php-sdk
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Copyright (c) 2019 - present |
||
| 4 | * updown - helpers.php |
||
| 5 | * author: Roberto Belotti - [email protected] |
||
| 6 | * web : robertobelotti.com, github.com/biscolab |
||
| 7 | * Initial version created on: 15/2/2019 |
||
| 8 | * MIT license: https://github.com/biscolab/updown-php/blob/master/LICENSE |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Biscolab\UpDown; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @param string $camel |
||
| 15 | * |
||
| 16 | * @return string |
||
| 17 | */ |
||
| 18 | function camel2Snake(string $camel): string |
||
| 19 | { |
||
| 20 | |||
| 21 | return preg_replace('/^_/', '', strtolower(implode('_', preg_split('/(?=[A-Z])/', $camel)))); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param string $snake |
||
| 26 | * |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | function snake2Camel(string $snake): string |
||
| 30 | { |
||
| 31 | |||
| 32 | return lcfirst(preg_replace('/_/', '', ucwords($snake, '_'))); |
||
| 33 | } |