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