Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3.0327 |
Changes | 0 |
1 | <?php |
||
64 | 9 | public function tokenize( $string ) { |
|
65 | |||
66 | 9 | if ( $this->tokenizer !== null ) { |
|
67 | 1 | $string = implode( " ", $this->tokenizer->tokenize( $string ) ); |
|
68 | 1 | } |
|
69 | |||
70 | // (?<=\p{L})(?=\p{N}) to split alphanumeric and numeric |
||
71 | |||
72 | 9 | $pattern = str_replace( |
|
73 | 9 | $this->patternExemption, |
|
74 | 9 | '', |
|
75 | '([\s\-_,:;?!%\'\|\/\(\)\[\]{}<>\r\n"]|(?<!\d)\.(?!\d)|(?<=\p{L})(?=\p{N}))' |
||
76 | 9 | ); |
|
77 | |||
78 | 9 | $result = preg_split( '/' . $pattern . '/u', $string, null, PREG_SPLIT_NO_EMPTY ); |
|
79 | |||
80 | 9 | if ( $result === false ) { |
|
81 | $result = array(); |
||
82 | } |
||
83 | |||
84 | 9 | return $result; |
|
85 | } |
||
86 | |||
88 |