Skip to content

Commit 2b094cc

Browse files
committed
add: toLowerCamelCase.
1 parent 6367c57 commit 2b094cc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/SDK/Language.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,22 @@ protected function toCamelCase($str): string
106106
return $str;
107107
}
108108

109+
protected function toLowerCamelCase($str): string
110+
{
111+
// Normalize the string to decompose accented characters
112+
$str = \Normalizer::normalize($str, \Normalizer::FORM_D);
113+
114+
// Remove accents and other residual non-ASCII characters
115+
$str = preg_replace('/\p{M}/u', '', $str);
116+
117+
// Replace non-alphanumeric characters with a space
118+
$str = preg_replace('/[^a-zA-Z0-9]+/', ' ', $str);
119+
$str = ucwords(strtolower($str));
120+
$str = lcfirst(str_replace(' ', '', $str));
121+
122+
return $str;
123+
}
124+
109125
protected function toSnakeCase($str): string
110126
{
111127
// Normalize the string to decompose accented characters

0 commit comments

Comments
 (0)