| Conditions | 5 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 17 | 22 | public function call(?BaseToken ...$parameters): BaseToken |
|
| 18 | { |
||
| 19 | 22 | $separator = $this->parseParameter($parameters, numParam: 0); |
|
| 20 | |||
| 21 | 22 | if (!$separator || !is_string($separator->getValue())) { |
|
| 22 | 4 | $newValue = [$this->token->getValue()]; |
|
|
|
|||
| 23 | } else { |
||
| 24 | 18 | $params = [$separator->getValue(), $this->token->getValue()]; |
|
| 25 | 18 | $limit = $this->parseParameter($parameters, numParam: 1); |
|
| 26 | |||
| 27 | 18 | if ($limit !== null) { |
|
| 28 | 4 | $params[] = (int) $limit->getValue(); |
|
| 29 | } |
||
| 30 | |||
| 31 | 18 | if ($separator instanceof TokenRegex) { |
|
| 32 | 4 | $func = 'preg_split'; |
|
| 33 | } else { |
||
| 34 | 14 | $func = 'explode'; |
|
| 35 | } |
||
| 36 | |||
| 37 | 18 | $newValue = $func(...$params); |
|
| 38 | } |
||
| 39 | |||
| 40 | 22 | return new TokenArray($newValue); |
|
| 41 | } |
||
| 43 |