Conditions | 2 |
Paths | 2 |
Total Lines | 25 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
20 | public function leaveNode(Node $node) |
||
21 | { |
||
22 | if (!$node instanceof Spaceship) { |
||
23 | return; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Replacing |
||
28 | * $a <=> $b |
||
29 | * with |
||
30 | * $a < $b ? -1 : ($a == $b ? 0 : 1) |
||
31 | */ |
||
32 | |||
33 | $attributes = $node->getAttributes(); |
||
34 | |||
35 | $smaller = new UnaryMinus(new LNumber(1, $attributes), $attributes); |
||
36 | $equal = new LNumber(0, $attributes); |
||
37 | $larger = new LNumber(1, $attributes); |
||
38 | |||
39 | $isEqual = new Equal($node->left, $node->right, $attributes); |
||
40 | $isSmaller = new Smaller($node->left, $node->right, $attributes); |
||
41 | |||
42 | $else = new Ternary($isEqual, $equal, $larger, $attributes); |
||
43 | return new Ternary($isSmaller, $smaller, $else, $attributes); |
||
44 | } |
||
45 | } |
||
46 |