Conditions | 8 |
Paths | 7 |
Total Lines | 36 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 8.0291 |
Changes | 5 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
8785 | 16 | public static function str_to_words( |
|
8786 | string $str, |
||
8787 | string $char_list = '', |
||
8788 | bool $remove_empty_values = false, |
||
8789 | int $remove_short_values = null |
||
8790 | ): array { |
||
8791 | 16 | if ($str === '') { |
|
8792 | 4 | return $remove_empty_values ? [] : ['']; |
|
8793 | } |
||
8794 | |||
8795 | 16 | $char_list = self::rxClass($char_list, '\pL'); |
|
8796 | |||
8797 | 16 | $return = \preg_split("/({$char_list}+(?:[\p{Pd}’']{$char_list}+)*)/u", $str, -1, \PREG_SPLIT_DELIM_CAPTURE); |
|
8798 | 16 | if ($return === false) { |
|
8799 | return $remove_empty_values ? [] : ['']; |
||
8800 | } |
||
8801 | |||
8802 | if ( |
||
8803 | 16 | $remove_short_values === null |
|
8804 | && |
||
8805 | !$remove_empty_values |
||
8806 | ) { |
||
8807 | 16 | return $return; |
|
8808 | } |
||
8809 | |||
8810 | 2 | $tmp_return = self::reduce_string_array( |
|
8811 | $return, |
||
8812 | $remove_empty_values, |
||
8813 | $remove_short_values |
||
8814 | ); |
||
8815 | |||
8816 | 2 | foreach ($tmp_return as &$item) { |
|
8817 | 2 | $item = (string) $item; |
|
8818 | } |
||
8819 | |||
8820 | 2 | return $tmp_return; |
|
8821 | } |
||
13722 |