Conditions | 5 |
Paths | 3 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
13 | 1 | public function fix(\SplFileInfo $file, $content) |
|
14 | { |
||
15 | 1 | $tokens = Tokens::fromCode($content); |
|
16 | |||
17 | 1 | for ($index = 2; $index < count($tokens); $index++) { |
|
|
|||
18 | 1 | $token = $tokens[$index]; |
|
19 | 1 | $previousToken = $tokens[$index - 1]; |
|
20 | 1 | $sndPreviousToken = $tokens[$index - 2]; |
|
21 | 1 | if ($sndPreviousToken->getContent() !== '{' && |
|
22 | 1 | substr($token->getContent(), 0, 3) === '/**' && |
|
23 | 1 | $previousToken->getLine() === $token->getLine() - 1 |
|
24 | ) { |
||
25 | 1 | $previousToken->setContent(PHP_EOL . $previousToken->getContent()); |
|
26 | } |
||
27 | } |
||
28 | |||
29 | 1 | return $tokens->generateCode(); |
|
30 | } |
||
31 | |||
40 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: