| Conditions | 4 |
| Paths | 5 |
| Total Lines | 29 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 18 | public function call($glue = null): BaseToken |
|
| 27 | { |
||
| 28 | 18 | if (!$this->token instanceof TokenArray) { |
|
| 29 | 2 | throw new ParserException(sprintf( |
|
| 30 | 2 | '%s.join is not a function at position %d on line %d', |
|
| 31 | 2 | $this->token->getValue(), |
|
| 32 | 2 | $this->token->getPosition(), |
|
| 33 | 2 | $this->token->getLine() |
|
| 34 | )); |
||
| 35 | } |
||
| 36 | |||
| 37 | 16 | if ($glue) { |
|
| 38 | 14 | $glue = $glue->getValue(); |
|
| 39 | } else { |
||
| 40 | 2 | $glue = ','; |
|
| 41 | } |
||
| 42 | |||
| 43 | 16 | $array = $this->token->getValue(); |
|
| 44 | |||
| 45 | 16 | if ($array instanceof TokenCollection) { |
|
| 46 | 14 | $array = $array->toArray(); |
|
| 47 | } |
||
| 48 | |||
| 49 | 16 | return new TokenString( |
|
| 50 | 16 | implode($glue, $array), |
|
| 51 | 16 | $this->token->getOffset(), |
|
| 52 | 16 | $this->token->getStack() |
|
| 53 | ); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |