Conditions | 20 |
Paths | 20 |
Total Lines | 48 |
Code Lines | 37 |
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 |
||
114 | protected function operatorExpression(QueryExpression $exp, $operator, $field, $value) |
||
115 | { |
||
116 | switch ($operator) { |
||
117 | case 'eq': |
||
118 | case '=': |
||
119 | $exp = $exp->eq($field, $value); |
||
120 | break; |
||
121 | |||
122 | case 'neq': |
||
123 | case 'ne': |
||
124 | case '!=': |
||
125 | case '<>': |
||
126 | $exp = $exp->notEq($field, $value); |
||
127 | break; |
||
128 | |||
129 | case 'lt': |
||
130 | case '<': |
||
131 | $exp = $exp->lt($field, $value); |
||
132 | break; |
||
133 | |||
134 | case 'lte': |
||
135 | case 'le': |
||
136 | case '<=': |
||
137 | $exp = $exp->lte($field, $value); |
||
138 | break; |
||
139 | |||
140 | case 'gt': |
||
141 | case '>': |
||
142 | $exp = $exp->gt($field, $value); |
||
143 | break; |
||
144 | |||
145 | case 'gte': |
||
146 | case 'ge': |
||
147 | case '>=': |
||
148 | $exp = $exp->gte($field, $value); |
||
149 | break; |
||
150 | |||
151 | case 'null': |
||
152 | $op = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); |
||
153 | if ($op === false) { |
||
154 | $exp = $exp->isNotNull($field); |
||
155 | } elseif ($op === true) { |
||
156 | $exp = $exp->isNull($field); |
||
157 | } |
||
158 | break; |
||
159 | } |
||
160 | |||
161 | return $exp; |
||
162 | } |
||
164 |