Conditions | 5 |
Paths | 12 |
Total Lines | 44 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5.1158 |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
4476 | 46 | public static function lcfirst( |
|
4477 | string $str, |
||
4478 | string $encoding = 'UTF-8', |
||
4479 | bool $clean_utf8 = false, |
||
4480 | string $lang = null, |
||
4481 | bool $try_to_keep_the_string_length = false |
||
4482 | ): string { |
||
4483 | 46 | if ($clean_utf8) { |
|
4484 | $str = self::clean($str); |
||
4485 | } |
||
4486 | |||
4487 | 46 | $use_mb_functions = ($lang === null && !$try_to_keep_the_string_length); |
|
4488 | |||
4489 | 46 | if ($encoding === 'UTF-8') { |
|
4490 | 43 | $str_part_two = (string) \mb_substr($str, 1); |
|
4491 | |||
4492 | 43 | if ($use_mb_functions) { |
|
4493 | 43 | $str_part_one = \mb_strtolower( |
|
4494 | 43 | (string) \mb_substr($str, 0, 1) |
|
4495 | ); |
||
4496 | } else { |
||
4497 | 43 | $str_part_one = self::strtolower( |
|
4498 | (string) \mb_substr($str, 0, 1), |
||
4499 | $encoding, |
||
4500 | false, |
||
4501 | $lang, |
||
4502 | $try_to_keep_the_string_length |
||
4503 | ); |
||
4504 | } |
||
4505 | } else { |
||
4506 | 3 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
|
4507 | |||
4508 | 3 | $str_part_two = (string) self::substr($str, 1, null, $encoding); |
|
4509 | |||
4510 | 3 | $str_part_one = self::strtolower( |
|
4511 | 3 | (string) self::substr($str, 0, 1, $encoding), |
|
4512 | $encoding, |
||
4513 | 3 | false, |
|
4514 | $lang, |
||
4515 | $try_to_keep_the_string_length |
||
4516 | ); |
||
4517 | } |
||
4518 | |||
4519 | 46 | return $str_part_one . $str_part_two; |
|
4520 | } |
||
14812 |