feat(utils): added misc functions file with utilities
Added useful misc utilities that don't belong in a specific class/domain and should be available globally.
This commit is contained in:
parent
4c4e6d4c99
commit
f8467ada09
@ -9,6 +9,9 @@
|
||||
"php-di/slim-bridge": "^3.4"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"src/Utils/Functions.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Models\\": "src/Models/",
|
||||
"Interfaces\\": "src/Interfaces",
|
||||
|
25
src/Utils/Functions.php
Normal file
25
src/Utils/Functions.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Converts camelCase to snake_case.
|
||||
*
|
||||
* @see https://gist.github.com/carousel/1aacbea013d230768b3dec1a14ce5751
|
||||
* @param $input
|
||||
* @return string
|
||||
*/
|
||||
function camel_to_snake($input)
|
||||
{
|
||||
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts snake_case to camelCase.
|
||||
*
|
||||
* @see https://gist.github.com/carousel/1aacbea013d230768b3dec1a14ce5751
|
||||
* @param $input
|
||||
* @return string
|
||||
*/
|
||||
function snakeToCamel($input)
|
||||
{
|
||||
return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $input))));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user