| Conditions | 17 |
| Paths | 45 |
| Total Lines | 42 |
| Code Lines | 23 |
| 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 |
||
| 41 | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data) |
||
| 42 | { |
||
| 43 | //check data sanity |
||
| 44 | if (true !== is_array($data)) { |
||
| 45 | return; |
||
| 46 | } |
||
| 47 | |||
| 48 | //default type for simple filter |
||
| 49 | $data['type'] = !isset($data['type']) || !is_numeric($data['type']) ? DateType::TYPE_EQUAL : $data['type']; |
||
| 50 | |||
| 51 | // Some types do not require a value to be set (NULL, NOT NULL). |
||
| 52 | if (!$this->typeRequiresValue($data['type']) && !$data['value']) { |
||
| 53 | return; |
||
| 54 | } |
||
| 55 | |||
| 56 | switch ($data['type']) { |
||
| 57 | case DateType::TYPE_EQUAL: |
||
| 58 | return $this->applyTypeIsEqual($queryBuilder, $field, $data); |
||
|
|
|||
| 59 | |||
| 60 | case DateType::TYPE_GREATER_THAN: |
||
| 61 | if (!array_key_exists('value', $data) || !$data['value']) { |
||
| 62 | return; |
||
| 63 | } |
||
| 64 | |||
| 65 | return $this->applyTypeIsGreaterThan($queryBuilder, $field, $data); |
||
| 66 | |||
| 67 | case DateType::TYPE_LESS_EQUAL: |
||
| 68 | if (!array_key_exists('value', $data) || !$data['value']) { |
||
| 69 | return; |
||
| 70 | } |
||
| 71 | |||
| 72 | return $this->applyTypeIsLessEqual($queryBuilder, $field, $data); |
||
| 73 | |||
| 74 | case DateType::TYPE_NULL: |
||
| 75 | case DateType::TYPE_NOT_NULL: |
||
| 76 | return $this->applyType($queryBuilder, $this->getOperator($data['type']), $field, null); |
||
| 77 | |||
| 78 | case DateType::TYPE_GREATER_EQUAL: |
||
| 79 | case DateType::TYPE_LESS_THAN: |
||
| 80 | return $this->applyType($queryBuilder, $this->getOperator($data['type']), $field, $data['value']); |
||
| 81 | } |
||
| 82 | } |
||
| 83 | |||
| 163 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.