| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4.0582 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 10 | public function repair(TokenCollection $tokens) { |
|
| 16 | 10 | $fixedTokens = new TokenCollection(); |
|
| 17 | |||
| 18 | 10 | for ($i = 0, $n = $tokens->size(); $i < $n; $i++) { |
|
| 19 | 10 | $token = $tokens->get($i); |
|
| 20 | |||
| 21 | // fix ELSEIF |
||
| 22 | 10 | if ($token->type == T_ELSE) { |
|
| 23 | 5 | $nextToken = $tokens->get($i + 1); |
|
| 24 | |||
| 25 | 5 | if ($nextToken->type == T_IF) { |
|
| 26 | $i++; |
||
| 27 | $fixedTokens->add(new Token([T_ELSEIF, 'else if'])); |
||
| 28 | } else { |
||
| 29 | 5 | $fixedTokens->add($token); |
|
| 30 | } |
||
| 31 | |||
| 32 | 5 | continue; |
|
| 33 | } |
||
| 34 | |||
| 35 | 10 | $fixedTokens->add($token); |
|
| 36 | } |
||
| 37 | 10 | return $fixedTokens; |
|
| 38 | } |
||
| 39 | |||
| 51 |