| Conditions | 11 |
| Paths | 31 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 24 | protected function compile($expr, Context $context) |
||
| 25 | { |
||
| 26 | $left = $context->getExpressionCompiler()->compile($expr->left); |
||
| 27 | $right = $context->getExpressionCompiler()->compile($expr->right); |
||
| 28 | |||
| 29 | switch ($left->getType()) { |
||
| 30 | case CompiledExpression::INTEGER: |
||
| 31 | case CompiledExpression::DOUBLE: |
||
| 32 | case CompiledExpression::BOOLEAN: |
||
| 33 | case CompiledExpression::NUMBER: |
||
| 34 | case CompiledExpression::NULL: |
||
| 35 | switch ($right->getType()) { |
||
| 36 | case CompiledExpression::INTEGER: |
||
| 37 | case CompiledExpression::DOUBLE: |
||
| 38 | case CompiledExpression::BOOLEAN: |
||
| 39 | case CompiledExpression::NUMBER: |
||
| 40 | case CompiledExpression::NULL: |
||
| 41 | return new CompiledExpression( |
||
| 42 | CompiledExpression::INTEGER, |
||
| 43 | $left->getValue() <=> $right->getValue() |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | } |
||
| 47 | |||
| 48 | return new CompiledExpression(CompiledExpression::BOOLEAN); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |