| Conditions | 14 |
| Paths | 8 |
| Total Lines | 36 |
| Code Lines | 21 |
| 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 |
||
| 27 | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data) |
||
| 28 | { |
||
| 29 | if (!$data || !is_array($data) || !array_key_exists('type', $data) || !array_key_exists('value', $data)) { |
||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (is_array($data['value'])) { |
||
| 34 | if (count($data['value']) == 0) { |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | |||
| 38 | if (in_array('all', $data['value'])) { |
||
| 39 | return; |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) { |
||
| 43 | $queryBuilder->field($field)->notIn($data['value']); |
||
| 44 | } else { |
||
| 45 | $queryBuilder->field($field)->in($data['value']); |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->active = true; |
||
| 49 | } else { |
||
| 50 | if ($data['value'] === '' || $data['value'] === null || $data['value'] === false || $data['value'] === 'all') { |
||
| 51 | return; |
||
| 52 | } |
||
| 53 | |||
| 54 | if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) { |
||
| 55 | $queryBuilder->field($field)->notEqual($data['value']); |
||
| 56 | } else { |
||
| 57 | $queryBuilder->field($field)->equals($data['value']); |
||
| 58 | } |
||
| 59 | |||
| 60 | $this->active = true; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 82 |