Conditions | 10 |
Paths | 9 |
Total Lines | 30 |
Code Lines | 15 |
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 |
||
55 | protected function processMultiple(Model $entity, Request $request, $field) |
||
56 | { |
||
57 | //$request->validate($entity->getMediaFieldsValidation($field)); |
||
58 | $validator = \Validator::make($request->only($field), $entity->getMediaFieldsValidation($field)); |
||
59 | |||
60 | if ($validator->fails()) { |
||
61 | return redirect()->back()->withErrors($validator)->withInput(); |
||
62 | } |
||
63 | |||
64 | if ($request->hasFile($field)) { |
||
65 | //$entity->addMultipleMediaFromRequest([$field])->each(function ($fileAdder) use ($field) { |
||
66 | // $fileAdder->toMediaCollection($field); |
||
67 | //}); |
||
68 | foreach ($request->file($field) as $file) { |
||
69 | $this->add($entity, $file, $field); |
||
70 | } |
||
71 | } |
||
72 | |||
73 | $weightSuffix = config('medialibrary-extension.field_suffixes.weight', '_weight'); |
||
74 | if (($weight = $request->get($field . $weightSuffix)) && is_array($weight)) { |
||
75 | foreach ($weight as $key => $value) { |
||
76 | $entity->media()->where('id', $key)->update(['order_column' => $value]); |
||
77 | } |
||
78 | } |
||
79 | |||
80 | $deletedSuffix = config('medialibrary-extension.field_suffixes.deleted', '_deleted'); |
||
81 | if (($ids = $request->get($field . $deletedSuffix)) && is_array($ids)) { |
||
82 | array_map(function($id) use ($entity) { |
||
83 | $id ? $entity->deleteMedia($id) : null; |
||
84 | }, $ids); |
||
85 | } |
||
111 | } |
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