| Conditions | 10 |
| Paths | 18 |
| Total Lines | 28 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 66 | private function compareValues(string $operator, string $type, $value, $compareValue): bool |
||
| 67 | { |
||
| 68 | if ($type === self::TYPE_NUMBER) { |
||
| 69 | $value = (float) $value; |
||
| 70 | $compareValue = (float)$compareValue; |
||
| 71 | } else { |
||
| 72 | $value = (string) $value; |
||
| 73 | $compareValue = (string) $compareValue; |
||
| 74 | } |
||
| 75 | switch ($operator) { |
||
| 76 | case '==': |
||
| 77 | return $value == $compareValue; |
||
| 78 | case '===': |
||
| 79 | return $value === $compareValue; |
||
| 80 | case '!=': |
||
| 81 | return $value != $compareValue; |
||
| 82 | case '!==': |
||
| 83 | return $value !== $compareValue; |
||
| 84 | case '>': |
||
| 85 | return $value > $compareValue; |
||
| 86 | case '>=': |
||
| 87 | return $value >= $compareValue; |
||
| 88 | case '<': |
||
| 89 | return $value < $compareValue; |
||
| 90 | case '<=': |
||
| 91 | return $value <= $compareValue; |
||
| 92 | default: |
||
| 93 | return false; |
||
| 94 | } |
||
| 97 |