| Conditions | 10 |
| Paths | 10 |
| Total Lines | 32 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 121 | protected function operation(QueryBuilder\Condition $condition, array &$values): array |
||
| 122 | { |
||
| 123 | $columnKey = strval($condition->getColumnKey()); |
||
| 124 | switch ($condition->getOperation()) { |
||
| 125 | // case IQueryBuilder::OPERATION_NULL: |
||
| 126 | // return 'IS NULL'; |
||
| 127 | // case IQueryBuilder::OPERATION_NNULL: |
||
| 128 | // return 'IS NOT NULL'; |
||
| 129 | case IQueryBuilder::OPERATION_EQ: |
||
| 130 | return ['$eq' => $values[$columnKey]]; |
||
| 131 | case IQueryBuilder::OPERATION_NEQ: |
||
| 132 | return ['$ne' => $values[$columnKey]]; |
||
| 133 | case IQueryBuilder::OPERATION_GT: |
||
| 134 | return ['$gt' => $values[$columnKey]]; |
||
| 135 | case IQueryBuilder::OPERATION_GTE: |
||
| 136 | return ['$gte' => $values[$columnKey]]; |
||
| 137 | case IQueryBuilder::OPERATION_LT: |
||
| 138 | return ['$le' => $values[$columnKey]]; |
||
| 139 | case IQueryBuilder::OPERATION_LTE: |
||
| 140 | return ['$lte' => $values[$columnKey]]; |
||
| 141 | // case IQueryBuilder::OPERATION_LIKE: |
||
| 142 | // return 'LIKE'; |
||
| 143 | // case IQueryBuilder::OPERATION_NLIKE: |
||
| 144 | // return 'NOT LIKE'; |
||
| 145 | case IQueryBuilder::OPERATION_REXP: |
||
| 146 | return ['$regex' => $values[$columnKey]]; |
||
| 147 | case IQueryBuilder::OPERATION_IN: |
||
| 148 | return ['$in' => [$this->notEmptyArray($values[$columnKey])]]; |
||
| 149 | case IQueryBuilder::OPERATION_NIN: |
||
| 150 | return ['$nin' => [$this->notEmptyArray($values[$columnKey])]]; |
||
| 151 | default: |
||
| 152 | throw new MapperException(sprintf('Unknown operation *%s*', $condition->getOperation())); |
||
| 153 | } |
||
| 156 |