| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | protected function compile($expr, Context $context) |
||
| 22 | { |
||
| 23 | $condition = $context->getExpressionCompiler()->compile($expr->cond); |
||
| 24 | $left = $context->getExpressionCompiler()->compile($expr->if); |
||
|
|
|||
| 25 | $right = $context->getExpressionCompiler()->compile($expr->else); |
||
| 26 | |||
| 27 | if ($condition->getValue() == true) { |
||
| 28 | return CompiledExpression::fromZvalValue($left->getValue()); |
||
| 29 | } else { |
||
| 30 | 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: