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 |
||
5786 | 49 | public static function str_delimit( |
|
5787 | string $str, |
||
5788 | string $delimiter, |
||
5789 | string $encoding = 'UTF-8', |
||
5790 | bool $clean_utf8 = false, |
||
5791 | string $lang = null, |
||
5792 | bool $try_to_keep_the_string_length = false |
||
5793 | ): string { |
||
5794 | 49 | if (self::$SUPPORT['mbstring'] === true) { |
|
5795 | 49 | $str = (string) \mb_ereg_replace('\\B(\\p{Lu})', '-\1', \trim($str)); |
|
5796 | |||
5797 | 49 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
|
5798 | 49 | if ($use_mb_functions && $encoding === 'UTF-8') { |
|
5799 | 22 | $str = \mb_strtolower($str); |
|
5800 | } else { |
||
5801 | 27 | $str = self::strtolower($str, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length); |
|
5802 | } |
||
5803 | |||
5804 | 49 | return (string) \mb_ereg_replace('[\\-_\\s]+', $delimiter, $str); |
|
5805 | } |
||
5806 | |||
5807 | $str = (string) \preg_replace('/\\B(\\p{Lu})/u', '-\1', \trim($str)); |
||
5808 | |||
5809 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
||
5810 | if ($use_mb_functions && $encoding === 'UTF-8') { |
||
5811 | $str = \mb_strtolower($str); |
||
5812 | } else { |
||
5813 | $str = self::strtolower($str, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length); |
||
5814 | } |
||
5815 | |||
5816 | return (string) \preg_replace('/[\\-_\\s]+/u', $delimiter, $str); |
||
5817 | } |
||
13722 |