Conditions | 9 |
Paths | 1 |
Total Lines | 56 |
Code Lines | 45 |
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 |
||
70 | public function filters(): array |
||
71 | { |
||
72 | return [ |
||
73 | SelectFilter::make('Active') |
||
74 | ->options([ |
||
75 | '' => 'All', |
||
76 | '1' => 'Active', |
||
77 | '0' => 'Inactive', |
||
78 | ]) |
||
79 | ->filter(function (Builder $builder, string $value) { |
||
80 | if ($value === '1') { |
||
81 | $builder->where('active', true); |
||
82 | } elseif ($value === '0') { |
||
83 | $builder->where('active', false); |
||
84 | } |
||
85 | }), |
||
86 | SelectFilter::make('Featured') |
||
87 | ->options([ |
||
88 | '' => 'All', |
||
89 | '1' => 'Featured', |
||
90 | '0' => 'Not Featured', |
||
91 | ]) |
||
92 | ->filter(function (Builder $builder, string $value) { |
||
93 | if ($value === '1') { |
||
94 | $builder->where('featured', true); |
||
95 | } elseif ($value === '0') { |
||
96 | $builder->where('featured', false); |
||
97 | } |
||
98 | }), |
||
99 | SelectFilter::make('Status') |
||
100 | ->options([ |
||
101 | '' => 'All', |
||
102 | '0' => 'Not Approved', |
||
103 | '1' => 'Published', |
||
104 | '2' => 'Pending', |
||
105 | '3' => 'Draft', |
||
106 | ]) |
||
107 | ->filter(function (Builder $builder, string $value) { |
||
108 | if ($value === '0') { |
||
109 | $builder->where('status', 0); |
||
110 | } elseif ($value === '1') { |
||
111 | $builder->where('status', 1); |
||
112 | } elseif ($value === '2') { |
||
113 | $builder->where('status', 2); |
||
114 | } elseif ($value === '3') { |
||
115 | $builder->where('status', 3); |
||
116 | } |
||
117 | }), |
||
118 | SelectFilter::make('Author') |
||
119 | ->options(array_merge([ |
||
120 | '' => 'All', |
||
121 | ], User::find(array_unique(Post::pluck('id')->toArray()))->mapWithKeys(function ($user) { |
||
122 | return [$user->id => $user->name]; |
||
123 | })->toArray())) |
||
124 | ->filter(function (Builder $builder, string $value) { |
||
125 | $builder->where('user_id', (int) $value); |
||
126 | }), |
||
199 |
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