Conditions | 10 |
Paths | 18 |
Total Lines | 23 |
Code Lines | 15 |
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 |
||
55 | protected function buildCompositeInCondition(?string $operator, $columns, $values, array &$params = []): string |
||
56 | { |
||
57 | $quotedColumns = []; |
||
58 | foreach ($columns as $i => $column) { |
||
59 | $quotedColumns[$i] = strpos($column, '(') === false |
||
60 | ? $this->queryBuilder->getDb()->quoteColumnName($column) : $column; |
||
61 | } |
||
62 | |||
63 | $vss = []; |
||
64 | foreach ($values as $value) { |
||
65 | $vs = []; |
||
66 | foreach ($columns as $i => $column) { |
||
67 | if (isset($value[$column])) { |
||
68 | $phName = $this->queryBuilder->bindParam($value[$column], $params); |
||
69 | $vs[] = $quotedColumns[$i] . ($operator === 'IN' ? ' = ' : ' != ') . $phName; |
||
70 | } else { |
||
71 | $vs[] = $quotedColumns[$i] . ($operator === 'IN' ? ' IS' : ' IS NOT') . ' NULL'; |
||
72 | } |
||
73 | } |
||
74 | $vss[] = '(' . implode($operator === 'IN' ? ' AND ' : ' OR ', $vs) . ')'; |
||
75 | } |
||
76 | |||
77 | return '(' . implode($operator === 'IN' ? ' OR ' : ' AND ', $vss) . ')'; |
||
78 | } |
||
80 |