Conditions | 8 |
Paths | 7 |
Total Lines | 36 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 8.0155 |
Changes | 5 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
8738 | public static function str_to_words( |
||
8739 | string $str, |
||
8740 | string $char_list = '', |
||
8741 | bool $remove_empty_values = false, |
||
8742 | int $remove_short_values = null |
||
8743 | ): array { |
||
8744 | 16 | if ($str === '') { |
|
8745 | 4 | return $remove_empty_values ? [] : ['']; |
|
8746 | } |
||
8747 | |||
8748 | 16 | $char_list = self::rxClass($char_list, '\pL'); |
|
8749 | |||
8750 | 16 | $return = \preg_split("/({$char_list}+(?:[\p{Pd}’']{$char_list}+)*)/u", $str, -1, \PREG_SPLIT_DELIM_CAPTURE); |
|
8751 | 16 | if ($return === false) { |
|
8752 | return $remove_empty_values ? [] : ['']; |
||
8753 | } |
||
8754 | |||
8755 | if ( |
||
8756 | 16 | $remove_short_values === null |
|
8757 | && |
||
8758 | 16 | !$remove_empty_values |
|
8759 | ) { |
||
8760 | 16 | return $return; |
|
8761 | } |
||
8762 | |||
8763 | 2 | $tmp_return = self::reduce_string_array( |
|
8764 | 2 | $return, |
|
8765 | 2 | $remove_empty_values, |
|
8766 | 2 | $remove_short_values |
|
8767 | ); |
||
8768 | |||
8769 | 2 | foreach ($tmp_return as &$item) { |
|
8770 | 2 | $item = (string) $item; |
|
8771 | } |
||
8772 | |||
8773 | 2 | return $tmp_return; |
|
8774 | } |
||
13693 |