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