| Conditions | 11 |
| Paths | 768 |
| Total Lines | 53 |
| Code Lines | 26 |
| 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 |
||
| 19 | public static function setBaseCustomFilterQuery( |
||
| 20 | Builder|BaseQueryBuilder $query, |
||
| 21 | array $filters |
||
| 22 | ): Builder|BaseQueryBuilder|Post { |
||
| 23 | if ($filters['tags'] !== null) { |
||
| 24 | $tags = array_filter((array) $filters['tags']); |
||
| 25 | |||
| 26 | $query = $query->whereHas('tags', function (BaseQueryBuilder|Builder $query) use ($tags): void { |
||
| 27 | $query->whereIn('tags.id', $tags); |
||
| 28 | }); |
||
| 29 | } |
||
| 30 | |||
| 31 | if ($filters['categories'] !== null) { |
||
| 32 | $categories = array_filter((array) $filters['categories']); |
||
| 33 | |||
| 34 | $query = $query->whereHas('categories', function (BaseQueryBuilder|Builder $query) use ($categories): void { |
||
| 35 | $query->whereIn('categories.id', $categories); |
||
| 36 | }); |
||
| 37 | } |
||
| 38 | |||
| 39 | if ($filters['categories_exclude'] !== null) { |
||
| 40 | $query = $query |
||
| 41 | ->whereHas('categories', function (BaseQueryBuilder|Builder $query) use ($filters): void { |
||
| 42 | $query->whereNotIn('categories.id', array_filter((array) $filters['categories_exclude'])); |
||
| 43 | }); |
||
| 44 | } |
||
| 45 | |||
| 46 | if ($filters['exclude'] !== null) { |
||
| 47 | $query = $query->whereNotIn('id', array_filter((array) $filters['exclude'])); |
||
| 48 | } |
||
| 49 | |||
| 50 | if ($filters['include'] !== null) { |
||
| 51 | $query = $query->whereNotIn('id', array_filter((array) $filters['include'])); |
||
| 52 | } |
||
| 53 | |||
| 54 | if ($filters['author'] !== null) { |
||
| 55 | $query = $query->whereIn('author_id', array_filter((array) $filters['author'])); |
||
| 56 | } |
||
| 57 | |||
| 58 | if ($filters['author_exclude'] !== null) { |
||
| 59 | $query = $query->whereNotIn('author_id', array_filter((array) $filters['author_exclude'])); |
||
| 60 | } |
||
| 61 | |||
| 62 | if ($filters['featured'] !== null) { |
||
| 63 | $query = $query->where('is_featured', $filters['featured']); |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($filters['search'] !== null) { |
||
| 67 | $keyword = isset($filters['search']) ? (string) $filters['search'] : null; |
||
| 68 | $query = self::search($query, $keyword); |
||
| 69 | } |
||
| 70 | |||
| 71 | return $query; |
||
| 72 | } |
||
| 104 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths