| Conditions | 10 |
| Paths | 18 |
| Total Lines | 22 |
| Code Lines | 15 |
| 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 |
||
| 18 | protected function buildCompositeInCondition($operator, $columns, $values, &$params) |
||
| 19 | { |
||
| 20 | $quotedColumns = []; |
||
| 21 | foreach ($columns as $i => $column) { |
||
| 22 | $quotedColumns[$i] = strpos($column, '(') === false ? $this->queryBuilder->db->quoteColumnName($column) : $column; |
||
| 23 | } |
||
| 24 | $vss = []; |
||
| 25 | foreach ($values as $value) { |
||
| 26 | $vs = []; |
||
| 27 | foreach ($columns as $i => $column) { |
||
| 28 | if (isset($value[$column])) { |
||
| 29 | $phName = $this->queryBuilder->bindParam($value[$column], $params); |
||
| 30 | $vs[] = $quotedColumns[$i] . ($operator === 'IN' ? ' = ' : ' != ') . $phName; |
||
| 31 | } else { |
||
| 32 | $vs[] = $quotedColumns[$i] . ($operator === 'IN' ? ' IS' : ' IS NOT') . ' NULL'; |
||
| 33 | } |
||
| 34 | } |
||
| 35 | $vss[] = '(' . implode($operator === 'IN' ? ' AND ' : ' OR ', $vs) . ')'; |
||
| 36 | } |
||
| 37 | |||
| 38 | return '(' . implode($operator === 'IN' ? ' OR ' : ' AND ', $vss) . ')'; |
||
| 39 | } |
||
| 40 | } |
||
| 41 |