Conditions | 15 |
Paths | 25 |
Total Lines | 34 |
Code Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
35 | public function __construct($left, string $operator, $right) |
||
36 | { |
||
37 | $this->leftOperand = $left; |
||
38 | $this->operator = $operator; |
||
39 | $this->binding = null; |
||
40 | |||
41 | switch (strtoupper($operator)) { |
||
42 | case '<': |
||
43 | case '<=': |
||
44 | case '>=': |
||
45 | case '>': |
||
46 | case '=': |
||
47 | case '<>': |
||
48 | case 'LIKE': |
||
49 | case 'NOT LIKE': |
||
50 | case 'IS': |
||
51 | case 'IS NOT': |
||
52 | if (is_array($right)) { |
||
53 | throw new QueryException("Array Unsupported for this operand type"); |
||
54 | } |
||
55 | $this->rightOperand = $right; |
||
56 | break; |
||
57 | |||
58 | case 'NOT IN': |
||
59 | case 'IN': |
||
60 | if (is_string($right)) { |
||
61 | $this->rightOperand = explode(', ', $right); |
||
62 | } else { |
||
63 | $this->rightOperand = $right; |
||
64 | } |
||
65 | break; |
||
66 | |||
67 | default: |
||
68 | throw new QueryException(sprintf("Unsupported operator \"%s\"", $operator)); |
||
69 | } |
||
118 |