| Conditions | 14 |
| Paths | 48 |
| Total Lines | 28 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 26 |
| CRAP Score | 14 |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 51 | 91 | public function getNativeValue() |
|
| 52 | { |
||
| 53 | 91 | $left = $this->left instanceof Node ? $this->left->getNativeValue() : $this->left; |
|
| 54 | 91 | $right = $this->right instanceof Node ? $this->right->getNativeValue() : $this->right; |
|
| 55 | |||
| 56 | 91 | switch ($this->operand) { |
|
| 57 | 91 | case self::ADD: |
|
| 58 | 2 | return $left + $right; |
|
| 59 | 90 | case self::OR_OPERATOR: |
|
| 60 | 1 | return $left | $right; |
|
| 61 | 90 | case self::AND_OPERATOR: |
|
| 62 | 1 | return $left & $right; |
|
| 63 | 90 | case self::SHIFT_LEFT: |
|
| 64 | 1 | return $left << $right; |
|
| 65 | 90 | case self::SHIFT_RIGHT: |
|
| 66 | 1 | return $left >> $right; |
|
| 67 | 90 | case self::SUB: |
|
| 68 | 2 | return $left - $right; |
|
| 69 | 89 | case self::MUL: |
|
| 70 | 1 | return $left * $right; |
|
| 71 | 89 | case self::DIV: |
|
| 72 | 1 | return $left / $right; |
|
| 73 | 89 | case self::MOD: |
|
| 74 | 1 | return $left % $right; |
|
| 75 | 89 | case self::POW: |
|
| 76 | 1 | return $left ** $right; |
|
| 77 | 88 | case self::CONCAT: |
|
| 78 | 88 | return $left . $right; |
|
| 79 | } |
||
| 82 |