| Conditions | 13 |
| Paths | 197 |
| Total Lines | 60 |
| Code Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 40 | public function edit(Request $request): View|RedirectResponse |
||
| 41 | { |
||
| 42 | $this->setAdminPrefs(); |
||
| 43 | $gen = new Genres; |
||
| 44 | $meta_title = $title = 'Console Edit'; |
||
| 45 | |||
| 46 | // set the current action |
||
| 47 | $action = $request->input('action', 'view'); |
||
| 48 | |||
| 49 | if ($request->has('id')) { |
||
| 50 | $id = $request->input('id'); |
||
| 51 | $con = $this->consoleService->getConsoleInfo($id); |
||
| 52 | |||
| 53 | if (! $con) { |
||
| 54 | abort(404); |
||
| 55 | } |
||
| 56 | |||
| 57 | switch ($action) { |
||
| 58 | case 'submit': |
||
| 59 | $coverLoc = storage_path('covers/console/'.$id.'.jpg'); |
||
| 60 | |||
| 61 | if ($request->hasFile('cover') && $request->file('cover')->isValid()) { |
||
| 62 | $uploadedFile = $request->file('cover'); |
||
| 63 | $file_info = getimagesize($uploadedFile->getRealPath()); |
||
| 64 | if (! empty($file_info)) { |
||
| 65 | $uploadedFile->move(storage_path('covers/console'), $id.'.jpg'); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | $hasCover = file_exists($coverLoc) ? 1 : 0; |
||
| 70 | $salesrank = (empty($request->input('salesrank')) || ! ctype_digit($request->input('salesrank'))) ? null : $request->input('salesrank'); |
||
| 71 | $releasedate = (empty($request->input('releasedate')) || ! strtotime($request->input('releasedate'))) |
||
| 72 | ? $con['releasedate'] |
||
| 73 | : Carbon::parse($request->input('releasedate'))->timestamp; |
||
| 74 | |||
| 75 | $this->consoleService->update( |
||
| 76 | $id, |
||
| 77 | $request->input('title'), |
||
| 78 | $request->input('asin'), |
||
| 79 | $request->input('url'), |
||
| 80 | $salesrank, |
||
| 81 | $request->input('platform'), |
||
| 82 | $request->input('publisher'), |
||
| 83 | $releasedate, |
||
| 84 | $request->input('esrb'), |
||
| 85 | $hasCover, |
||
| 86 | $request->input('genre') |
||
| 87 | ); |
||
| 88 | |||
| 89 | return redirect()->route('admin.console-list')->with('success', 'Console game updated successfully'); |
||
| 90 | |||
| 91 | case 'view': |
||
| 92 | default: |
||
| 93 | $genres = $gen->getGenres(Genres::CONSOLE_TYPE); |
||
| 94 | |||
| 95 | return view('admin.console.edit', compact('con', 'genres', 'title', 'meta_title')); |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | return redirect()->route('admin.console-list'); |
||
| 100 | } |
||
| 102 |
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