Conditions | 2 |
Paths | 2 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
16 | 2 | public function fix(NodeSearch $nodeSearch): bool |
|
17 | { |
||
18 | 2 | $found = false; |
|
19 | |||
20 | /** @var Node\Expr\BinaryOp\Spaceship $node */ |
||
21 | 2 | foreach ($nodeSearch->eachType(Node\Expr\BinaryOp\Spaceship::class) as $node) { |
|
22 | 2 | $found = true; |
|
23 | |||
24 | 2 | $newNode = new Node\Expr\Ternary( |
|
25 | 2 | new Node\Expr\BinaryOp\Smaller($node->left, $node->right), |
|
26 | 2 | new Node\Scalar\LNumber(-1), |
|
27 | 2 | new Node\Expr\Ternary( |
|
28 | 2 | new Node\Expr\BinaryOp\Equal($node->left, $node->right), |
|
29 | 2 | new Node\Scalar\LNumber(0), |
|
30 | 2 | new Node\Scalar\LNumber(1) |
|
31 | ) |
||
32 | ); |
||
33 | |||
34 | 2 | $nodeSearch->replaceNode($node, $newNode); |
|
35 | } |
||
36 | |||
37 | 2 | return $found; |
|
38 | } |
||
39 | } |
||
40 |