| Conditions | 12 |
| Paths | 12 |
| Total Lines | 37 |
| Code Lines | 33 |
| 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 |
||
| 45 | protected function parseConditions(QueryBuilder $queryBuilder, Condition $condition) |
||
| 46 | { |
||
| 47 | foreach ($condition->getConditions() as $cond) { |
||
| 48 | if (!\is_array($cond)) { |
||
| 49 | continue; |
||
| 50 | } |
||
| 51 | |||
| 52 | $cond = \array_values($cond); |
||
| 53 | $type = \array_shift($cond); |
||
| 54 | switch ($type) { |
||
| 55 | case Condition::EQUALS: |
||
| 56 | $this->parseSimpleCondition('=', $queryBuilder, $cond); |
||
| 57 | break; |
||
| 58 | case Condition::NOT_EQUALS: |
||
| 59 | $this->parseSimpleCondition('<>', $queryBuilder, $cond); |
||
| 60 | break; |
||
| 61 | case Condition::LESS_THAN: |
||
| 62 | $this->parseSimpleCondition('<', $queryBuilder, $cond); |
||
| 63 | break; |
||
| 64 | case Condition::GREATER_THAN: |
||
| 65 | $this->parseSimpleCondition('>', $queryBuilder, $cond); |
||
| 66 | break; |
||
| 67 | case Condition::LESS_OR_EQUALS: |
||
| 68 | $this->parseSimpleCondition('<=', $queryBuilder, $cond); |
||
| 69 | break; |
||
| 70 | case Condition::GREATER_OR_EQUALS: |
||
| 71 | $this->parseSimpleCondition('>=', $queryBuilder, $cond); |
||
| 72 | break; |
||
| 73 | case Condition::BETWEEN: |
||
| 74 | $this->parseBetweenCondition($queryBuilder, $cond); |
||
| 75 | break; |
||
| 76 | case Condition::LIKE: |
||
| 77 | $this->parseLikeCondition($queryBuilder, $cond); |
||
| 78 | break; |
||
| 79 | case Condition::IN: |
||
| 80 | $this->parseInCondition($queryBuilder, $cond); |
||
| 81 | break; |
||
| 82 | } |
||
| 152 |