| Conditions | 10 |
| Paths | 17 |
| Total Lines | 32 |
| Code Lines | 28 |
| 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 |
||
| 20 | public static function buildQuery(QueryBuilder $queryBuilder, FilterItemInterface $filterItem, string $fieldName) |
||
| 21 | { |
||
| 22 | if(empty($filterItem->getValue())) { |
||
| 23 | return ; |
||
| 24 | } |
||
| 25 | switch ($filterItem->getType()) { |
||
| 26 | case FilterItemInterface::TYPE_LIKE: |
||
| 27 | $expression = static::addLikeExpression($queryBuilder, $filterItem, $fieldName); |
||
| 28 | break; |
||
| 29 | case FilterItemInterface::TYPE_EQUAL: |
||
| 30 | $expression = static::addEqualExpression($queryBuilder, $filterItem, $fieldName); |
||
| 31 | break; |
||
| 32 | case FilterItemInterface::TYPE_NOT_EQUAL: |
||
| 33 | $expression = static::addNotEqualExpression($queryBuilder, $filterItem, $fieldName); |
||
| 34 | break; |
||
| 35 | case FilterItemInterface::TYPE_IN: |
||
| 36 | $expression = static::addInExpression($queryBuilder, $filterItem, $fieldName); |
||
|
|
|||
| 37 | break; |
||
| 38 | case FilterItemInterface::TYPE_NOT_IN: |
||
| 39 | $expression = static::addNotInExpression($queryBuilder, $filterItem, $fieldName); |
||
| 40 | break; |
||
| 41 | case FilterItemInterface::TYPE_IS_NULL: |
||
| 42 | $expression = static::addIsNullExpression($queryBuilder, $fieldName); |
||
| 43 | break; |
||
| 44 | case FilterItemInterface::TYPE_NOT_NULL: |
||
| 45 | $expression = static::addIsNotNullExpression($queryBuilder, $fieldName); |
||
| 46 | break; |
||
| 47 | default: $expression = null; |
||
| 48 | } |
||
| 49 | if($expression) { |
||
| 50 | $queryBuilder->andWhere( |
||
| 51 | $expression |
||
| 52 | ); |
||
| 166 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.