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