| Conditions | 15 |
| Paths | 15 |
| Total Lines | 35 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 146 | protected function initializePosts() |
||
| 147 | { |
||
| 148 | $filter = $this->filter_type; |
||
| 149 | if ($filter == 1) { |
||
| 150 | return Post::tenent()->with('author', 'tagged')->latest()->paginate(10); |
||
| 151 | } elseif ($filter == 2) { |
||
| 152 | return Post::tenent()->with('author', 'tagged')->today()->paginate(10); |
||
| 153 | } elseif ($filter == 3) { |
||
| 154 | return Post::tenent()->with('author', 'tagged')->week()->paginate(10); |
||
| 155 | } elseif ($filter == 4) { |
||
| 156 | return Post::tenent()->with('author', 'tagged')->month()->paginate(10); |
||
| 157 | } elseif ($filter == 5) { |
||
| 158 | return Post::tenent()->with('author', 'tagged')->year()->paginate(10); |
||
| 159 | } elseif ($filter == 6) { |
||
| 160 | $start = Carbon::create($this->startDate); |
||
| 161 | $end = Carbon::create($this->endDate); |
||
| 162 | return Post::tenent()->with('author', 'tagged')->whereBetween('updated_at', [$start->toDateString(), $end->toDateString()])->paginate(10); |
||
| 163 | } elseif ($filter == 7) { |
||
| 164 | return Post::tenent()->withAnyTag($this->tag_name)->with('author', 'tagged')->latest()->paginate(10); |
||
| 165 | } elseif ($filter == 8) { |
||
| 166 | return Post::tenent()->published()->with('author', 'tagged')->latest()->paginate(10); |
||
| 167 | } elseif ($filter == 9) { |
||
| 168 | return Post::tenent()->pending()->with('author', 'tagged')->latest()->paginate(10); |
||
| 169 | } elseif ($filter == 10) { |
||
| 170 | return Post::tenent()->featured()->with('author', 'tagged')->latest()->paginate(10); |
||
| 171 | } elseif ($filter == 11) { |
||
| 172 | return Post::tenent()->where('author_id', $this->user_id)->paginate(10); |
||
| 173 | } elseif ($filter == 12) { |
||
| 174 | return Post::tenent()->with('author', 'tagged')->orderBy('priority', 'desc')->paginate(10); |
||
| 175 | } elseif ($filter == 13) { |
||
| 176 | return Post::tenent()->with('author', 'tagged')->where('category_id', $this->categoryid)->latest()->paginate(10); |
||
| 177 | } elseif ($filter == 14) { |
||
| 178 | return $this->searchQuery()->tenent()->with('author', 'tagged')->latest()->paginate(10); |
||
| 179 | } else { |
||
| 180 | return Post::tenent()->with('author', 'tagged')->latest()->paginate(10)->paginate(10); |
||
| 181 | } |
||
| 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