| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 2 | protected function compile($expr, Context $context) |
|
| 22 | { |
||
| 23 | 2 | $condition = $context->getExpressionCompiler()->compile($expr->cond); |
|
| 24 | 2 | $left = $context->getExpressionCompiler()->compile($expr->if); |
|
|
|
|||
| 25 | 2 | $right = $context->getExpressionCompiler()->compile($expr->else); |
|
| 26 | |||
| 27 | 2 | if ($condition->getValue() == true) { |
|
| 28 | 1 | return CompiledExpression::fromZvalValue($left->getValue()); |
|
| 29 | } else { |
||
| 30 | 1 | return CompiledExpression::fromZvalValue($right->getValue()); |
|
| 31 | } |
||
| 32 | } |
||
| 33 | } |
||
| 34 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: