Conditions | 5 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
24 | 22 | public function call($separator = null, $limit = null): BaseToken |
|
25 | { |
||
26 | 22 | if (!$separator || !is_string($separator->getValue())) { |
|
27 | 4 | $newValue = [$this->token->getValue()]; |
|
28 | } else { |
||
29 | 18 | $params = [$separator->getValue(), $this->token->getValue()]; |
|
30 | |||
31 | 18 | if ($limit) { |
|
32 | 4 | $params[] = (int) $limit->getValue(); |
|
33 | } |
||
34 | |||
35 | 18 | if ($separator instanceof TokenRegex) { |
|
36 | 4 | $func = 'preg_split'; |
|
37 | } else { |
||
38 | 14 | $func = 'explode'; |
|
39 | } |
||
40 | |||
41 | 18 | $newValue = $func(...$params); |
|
42 | } |
||
43 | |||
44 | 22 | return new TokenArray( |
|
45 | 22 | $newValue, |
|
46 | 22 | $this->token->getOffset(), |
|
47 | 22 | $this->token->getStack() |
|
48 | ); |
||
49 | } |
||
50 | } |
||
51 |