| Conditions | 14 |
| Paths | 2050 |
| Total Lines | 78 |
| Code Lines | 46 |
| 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 |
||
| 37 | public function create(Request $request): void |
||
| 38 | { |
||
| 39 | $this->setAdminPrefs(); |
||
| 40 | |||
| 41 | switch ($request->input('action') ?? 'view') { |
||
| 42 | case 'submit': |
||
| 43 | $meta_title = $title = 'Add User Role'; |
||
| 44 | $role = Role::create([ |
||
| 45 | 'name' => $request->input('name'), |
||
| 46 | 'apirequests' => $request->input('apirequests'), |
||
| 47 | 'downloadrequests' => $request->input('downloadrequests'), |
||
| 48 | 'defaultinvites' => $request->input('defaultinvites'), |
||
| 49 | 'donation' => $request->input('donation') ?? 0, |
||
| 50 | 'addyears' => $request->input('addyears') ?? 0, |
||
| 51 | 'rate_limit' => $request->input('rate_limit'), |
||
| 52 | ]); |
||
| 53 | if ((int) $request->input('canpreview') === 1) { |
||
| 54 | $role->givePermissionTo('preview'); |
||
| 55 | } |
||
| 56 | |||
| 57 | if ((int) $request->input('hideads') === 1) { |
||
| 58 | $role->givePermissionTo('hideads'); |
||
| 59 | } |
||
| 60 | |||
| 61 | if ((int) $request->input('editrelease') === 1) { |
||
| 62 | $role->givePermissionTo('edit release'); |
||
| 63 | } |
||
| 64 | |||
| 65 | if ((int) $request->input('viewconsole') === 1) { |
||
| 66 | $role->givePermissionTo('view console'); |
||
| 67 | } |
||
| 68 | |||
| 69 | if ((int) $request->input('viewmovies') === 1) { |
||
| 70 | $role->givePermissionTo('view movies'); |
||
| 71 | } |
||
| 72 | |||
| 73 | if ((int) $request->input('viewaudio') === 1) { |
||
| 74 | $role->givePermissionTo('view audio'); |
||
| 75 | } |
||
| 76 | |||
| 77 | if ((int) $request->input('viewpc') === 1) { |
||
| 78 | $role->givePermissionTo('view pc'); |
||
| 79 | } |
||
| 80 | |||
| 81 | if ((int) $request->input('viewtv') === 1) { |
||
| 82 | $role->givePermissionTo('view tv'); |
||
| 83 | } |
||
| 84 | |||
| 85 | if ((int) $request->input('viewadult') === 1) { |
||
| 86 | $role->givePermissionTo('view adult'); |
||
| 87 | } |
||
| 88 | |||
| 89 | if ((int) $request->input('viewbooks') === 1) { |
||
| 90 | $role->givePermissionTo('view books'); |
||
| 91 | } |
||
| 92 | |||
| 93 | if ((int) $request->input('viewother') === 1) { |
||
| 94 | $role->givePermissionTo('view other'); |
||
| 95 | } |
||
| 96 | redirect()->to('admin/role-list')->sendHeaders(); |
||
| 97 | break; |
||
| 98 | case 'view': |
||
| 99 | default: |
||
| 100 | $meta_title = $title = 'Add User Role'; |
||
| 101 | $role = [ |
||
| 102 | ]; |
||
| 103 | |||
| 104 | break; |
||
| 105 | } |
||
| 106 | |||
| 107 | $this->smarty->assign('yesno_ids', [1, 0]); |
||
| 108 | $this->smarty->assign('yesno_names', ['Yes', 'No']); |
||
| 109 | |||
| 110 | $content = $this->smarty->fetch('role-add.tpl'); |
||
| 111 | |||
| 112 | $this->smarty->assign(compact('title', 'meta_title', 'content', 'role')); |
||
| 113 | |||
| 114 | $this->adminrender(); |
||
| 115 | } |
||
| 254 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.