Conditions | 5 |
Paths | 12 |
Total Lines | 44 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5.0488 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
4236 | 46 | public static function lcfirst( |
|
4237 | string $str, |
||
4238 | string $encoding = 'UTF-8', |
||
4239 | bool $clean_utf8 = false, |
||
4240 | string $lang = null, |
||
4241 | bool $try_to_keep_the_string_length = false |
||
4242 | ): string { |
||
4243 | 46 | if ($clean_utf8) { |
|
4244 | $str = self::clean($str); |
||
4245 | } |
||
4246 | |||
4247 | 46 | $use_mb_functions = ($lang === null && !$try_to_keep_the_string_length); |
|
4248 | |||
4249 | 46 | if ($encoding === 'UTF-8') { |
|
4250 | 43 | $str_part_two = (string) \mb_substr($str, 1); |
|
4251 | |||
4252 | 43 | if ($use_mb_functions) { |
|
4253 | 43 | $str_part_one = \mb_strtolower( |
|
4254 | 43 | (string) \mb_substr($str, 0, 1) |
|
4255 | ); |
||
4256 | } else { |
||
4257 | 43 | $str_part_one = self::strtolower( |
|
4258 | (string) \mb_substr($str, 0, 1), |
||
4259 | $encoding, |
||
4260 | false, |
||
4261 | $lang, |
||
4262 | $try_to_keep_the_string_length |
||
4263 | ); |
||
4264 | } |
||
4265 | } else { |
||
4266 | 3 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
|
4267 | |||
4268 | 3 | $str_part_two = (string) self::substr($str, 1, null, $encoding); |
|
4269 | |||
4270 | 3 | $str_part_one = self::strtolower( |
|
4271 | 3 | (string) self::substr($str, 0, 1, $encoding), |
|
4272 | $encoding, |
||
4273 | false, |
||
4274 | $lang, |
||
4275 | $try_to_keep_the_string_length |
||
4276 | ); |
||
4277 | } |
||
4278 | |||
4279 | 46 | return $str_part_one . $str_part_two; |
|
4280 | } |
||
13722 |