| Conditions | 6 |
| Paths | 5 |
| Total Lines | 65 |
| Code Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 14 | public function edit(Request $request) |
||
| 15 | { |
||
| 16 | $this->setAdminPrefs(); |
||
| 17 | |||
| 18 | // Set the current action. |
||
| 19 | $action = $request->input('action') ?? 'view'; |
||
| 20 | |||
| 21 | switch ($action) { |
||
| 22 | case 'submit': |
||
| 23 | $data = $request->all(); |
||
| 24 | |||
| 25 | // Handle fix_crap checkbox array - convert to comma-separated string |
||
| 26 | if (isset($data['fix_crap']) && is_array($data['fix_crap'])) { |
||
| 27 | $data['fix_crap'] = implode(',', $data['fix_crap']); |
||
| 28 | } elseif (! isset($data['fix_crap'])) { |
||
| 29 | // If no checkboxes selected, save empty string |
||
| 30 | $data['fix_crap'] = ''; |
||
| 31 | } |
||
| 32 | |||
| 33 | Settings::settingsUpdate($data); |
||
| 34 | |||
| 35 | return redirect()->to('admin/tmux-edit')->with('success', 'Tmux settings updated successfully'); |
||
| 36 | |||
| 37 | case 'view': |
||
| 38 | default: |
||
| 39 | break; |
||
| 40 | } |
||
| 41 | |||
| 42 | $meta_title = $title = 'Tmux Settings Edit'; |
||
| 43 | |||
| 44 | $this->viewData = array_merge($this->viewData, [ |
||
| 45 | 'site' => $this->settings, |
||
| 46 | 'yesno_ids' => [1, 0], |
||
| 47 | 'yesno_names' => ['yes', 'no'], |
||
| 48 | 'backfill_ids' => [0, 4, 1], |
||
| 49 | 'backfill_names' => ['Disabled', 'Safe', 'All'], |
||
| 50 | 'backfill_group_ids' => [1, 2, 3, 4, 5, 6], |
||
| 51 | 'backfill_group' => ['Newest', 'Oldest', 'Alphabetical', 'Alphabetical - Reverse', 'Most Posts', 'Fewest Posts'], |
||
| 52 | 'backfill_days' => ['Days per Group', 'Safe Backfill day'], |
||
| 53 | 'backfill_days_ids' => [1, 2], |
||
| 54 | 'dehash_ids' => [0, 1], |
||
| 55 | 'dehash_names' => ['Disabled', 'Enabled'], |
||
| 56 | 'import_ids' => [0, 1, 2], |
||
| 57 | 'import_names' => ['Disabled', 'Import - Do Not Use Filenames', 'Import - Use Filenames'], |
||
| 58 | 'releases_ids' => [0, 1], |
||
| 59 | 'releases_names' => ['Disabled', 'Update Releases'], |
||
| 60 | 'post_ids' => [0, 1, 2, 3], |
||
| 61 | 'post_names' => ['Disabled', 'PostProcess Additional', 'PostProcess NFOs', 'All'], |
||
| 62 | 'fix_crap_radio_ids' => ['Disabled', 'All', 'Custom'], |
||
| 63 | 'fix_crap_radio_names' => ['Disabled', 'All', 'Custom'], |
||
| 64 | 'fix_crap_check_ids' => ['blacklist', 'blfiles', 'executable', 'gibberish', 'hashed', 'installbin', 'passworded', 'passwordurl', 'sample', 'scr', 'short', 'size', 'huge', 'nzb', 'codec'], |
||
| 65 | 'fix_crap_check_names' => ['blacklist', 'blfiles', 'executable', 'gibberish', 'hashed', 'installbin', 'passworded', 'passwordurl', 'sample', 'scr', 'short', 'size', 'huge', 'nzb', 'codec'], |
||
| 66 | 'sequential_ids' => [0, 1], |
||
| 67 | 'sequential_names' => ['Disabled', 'Enabled'], |
||
| 68 | 'binaries_ids' => [0, 1], |
||
| 69 | 'binaries_names' => ['Disabled', 'Enabled'], |
||
| 70 | 'lookup_reqids_ids' => [0, 1, 2], |
||
| 71 | 'lookup_reqids_names' => ['Disabled', 'Lookup Request IDs', 'Lookup Request IDs Threaded'], |
||
| 72 | 'predb_ids' => [0, 1], |
||
| 73 | 'predb_names' => ['Disabled', 'Enabled'], |
||
| 74 | 'title' => $title, |
||
| 75 | 'meta_title' => $meta_title, |
||
| 76 | ]); |
||
| 77 | |||
| 78 | return view('admin.site.tmux-edit', $this->viewData); |
||
| 79 | } |
||
| 81 |