| Conditions | 10 |
| Paths | 10 |
| Total Lines | 32 |
| Code Lines | 28 |
| 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 |
||
| 134 | public function getContacts() |
||
| 135 | { |
||
| 136 | $filter = $this->filter; |
||
| 137 | $contacts = Contact::latest()->paginate(10); |
||
| 138 | |||
| 139 | if ($filter == 1) { |
||
| 140 | return $contacts; |
||
| 141 | } elseif ($filter == 2) { |
||
| 142 | return Contact::favorite()->paginate(10); |
||
| 143 | } elseif ($filter == 3) { |
||
| 144 | return Contact::nonFavorite()->paginate(10); |
||
| 145 | } elseif ($filter == 4) { |
||
| 146 | return Contact::active()->paginate(10); |
||
| 147 | } elseif ($filter == 5) { |
||
| 148 | return Contact::inActive()->paginate(10); |
||
| 149 | } elseif ($filter == 6) { |
||
| 150 | $start = Carbon::create($this->startDate); |
||
| 151 | $end = Carbon::create($this->endDate); |
||
| 152 | return Contact::whereBetween('updated_at', [$start->toDateString(), $end->toDateString()])->paginate(10); |
||
| 153 | } elseif ($filter == 7) { |
||
| 154 | return Contact::where('name', 'LIKE', '%' . $this->search . '%') |
||
| 155 | ->orWhere('address', 'LIKE', '%' . $this->search . '%') |
||
| 156 | ->orWhere('phone', 'LIKE', '%' . $this->search . '%') |
||
| 157 | ->orWhere('email', 'LIKE', '%' . $this->search . '%') |
||
| 158 | ->paginate(10); |
||
| 159 | } elseif ($filter == 8) { |
||
| 160 | $group = Group::find($this->group_filter_id); |
||
| 161 | if (isset($group)) { |
||
| 162 | return $group->contacts()->paginate(10); |
||
| 163 | } |
||
| 164 | } else { |
||
| 165 | return $contacts; |
||
| 166 | } |
||
| 176 |
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