| Conditions | 12 | 
| Paths | 26 | 
| Total Lines | 45 | 
| 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  | 
            ||
| 38 | public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)  | 
            ||
| 39 |     { | 
            ||
| 40 |         if (!$data || !\is_array($data) || !\array_key_exists('value', $data) || null === $data['value']) { | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 41 | return;  | 
            ||
| 42 | }  | 
            ||
| 43 | |||
| 44 | $data['value'] = trim($data['value']);  | 
            ||
| 45 | |||
| 46 |         if (0 === \strlen($data['value'])) { | 
            ||
| 47 | return;  | 
            ||
| 48 | }  | 
            ||
| 49 | $joinAlias = 'tff';  | 
            ||
| 50 |         $filterMode = $this->getOption('filter_mode'); | 
            ||
| 51 | |||
| 52 | // verify if the join is not already done  | 
            ||
| 53 | $aliasAlreadyExists = false;  | 
            ||
| 54 |         foreach ($queryBuilder->getDQLParts()['join'] as $joins) { | 
            ||
| 55 |             foreach ($joins as $join) { | 
            ||
| 56 |                 if ($join->getAlias() === $joinAlias) { | 
            ||
| 57 | $aliasAlreadyExists = true;  | 
            ||
| 58 | break 2;  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | }  | 
            ||
| 62 | |||
| 63 |         if (!$aliasAlreadyExists) { | 
            ||
| 64 | $queryBuilder->leftJoin($alias.'.translations', $joinAlias);  | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 |         if (TranslationFilterMode::GEDMO === $filterMode) { | 
            ||
| 68 | // search on translation OR on normal field when using Gedmo  | 
            ||
| 69 | $this->applyGedmoFilters($queryBuilder, $joinAlias, $alias, $field, $data);  | 
            ||
| 70 | |||
| 71 | $this->active = true;  | 
            ||
| 72 |         } elseif (TranslationFilterMode::KNPLABS === $filterMode) { | 
            ||
| 73 | // search on translation OR on normal field when using Knp  | 
            ||
| 74 | $this->applyKnplabsFilters($queryBuilder, $joinAlias, $field, $data);  | 
            ||
| 75 | |||
| 76 | $this->active = true;  | 
            ||
| 77 |         } else { | 
            ||
| 78 | throw new \LogicException(  | 
            ||
| 79 |                 sprintf('Invalid filter mode given: "%s"', $filterMode) | 
            ||
| 80 | );  | 
            ||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 156 | 
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.