Conditions | 8 |
Paths | 8 |
Total Lines | 31 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 13.0389 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5713 | 49 | public static function str_delimit( |
|
5714 | string $str, |
||
5715 | string $delimiter, |
||
5716 | string $encoding = 'UTF-8', |
||
5717 | bool $clean_utf8 = false, |
||
5718 | string $lang = null, |
||
5719 | bool $try_to_keep_the_string_length = false |
||
5720 | ): string { |
||
5721 | 49 | if (self::$SUPPORT['mbstring'] === true) { |
|
5722 | 49 | $str = (string) \mb_ereg_replace('\\B(\\p{Lu})', '-\1', \trim($str)); |
|
5723 | |||
5724 | 49 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
|
5725 | 49 | if ($use_mb_functions && $encoding === 'UTF-8') { |
|
5726 | 22 | $str = \mb_strtolower($str); |
|
5727 | } else { |
||
5728 | 27 | $str = self::strtolower($str, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length); |
|
5729 | } |
||
5730 | |||
5731 | 49 | return (string) \mb_ereg_replace('[\\-_\\s]+', $delimiter, $str); |
|
5732 | } |
||
5733 | |||
5734 | $str = (string) \preg_replace('/\\B(\\p{Lu})/u', '-\1', \trim($str)); |
||
5735 | |||
5736 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
||
5737 | if ($use_mb_functions && $encoding === 'UTF-8') { |
||
5738 | $str = \mb_strtolower($str); |
||
5739 | } else { |
||
5740 | $str = self::strtolower($str, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length); |
||
5741 | } |
||
5742 | |||
5743 | return (string) \preg_replace('/[\\-_\\s]+/u', $delimiter, $str); |
||
5744 | } |
||
13666 |