Conditions | 8 |
Paths | 7 |
Total Lines | 36 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 8.0189 |
Changes | 5 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
8769 | 16 | public static function str_to_words( |
|
8770 | string $str, |
||
8771 | string $char_list = '', |
||
8772 | bool $remove_empty_values = false, |
||
8773 | int $remove_short_values = null |
||
8774 | ): array { |
||
8775 | 16 | if ($str === '') { |
|
8776 | 4 | return $remove_empty_values ? [] : ['']; |
|
8777 | } |
||
8778 | |||
8779 | 16 | $char_list = self::rxClass($char_list, '\pL'); |
|
8780 | |||
8781 | 16 | $return = \preg_split("/({$char_list}+(?:[\p{Pd}’']{$char_list}+)*)/u", $str, -1, \PREG_SPLIT_DELIM_CAPTURE); |
|
8782 | 16 | if ($return === false) { |
|
8783 | return $remove_empty_values ? [] : ['']; |
||
8784 | } |
||
8785 | |||
8786 | if ( |
||
8787 | 16 | $remove_short_values === null |
|
8788 | && |
||
8789 | 16 | !$remove_empty_values |
|
8790 | ) { |
||
8791 | 16 | return $return; |
|
8792 | } |
||
8793 | |||
8794 | 2 | $tmp_return = self::reduce_string_array( |
|
8795 | 2 | $return, |
|
8796 | $remove_empty_values, |
||
8797 | $remove_short_values |
||
8798 | ); |
||
8799 | |||
8800 | 2 | foreach ($tmp_return as &$item) { |
|
8801 | 2 | $item = (string) $item; |
|
8802 | } |
||
8803 | |||
8804 | 2 | return $tmp_return; |
|
8805 | } |
||
13706 |