| Conditions | 14 |
| Paths | 2050 |
| Total Lines | 85 |
| Code Lines | 50 |
| 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 |
||
| 41 | public function create(Request $request): void |
||
| 42 | { |
||
| 43 | $this->setAdminPrefs(); |
||
| 44 | |||
| 45 | switch ($request->input('action') ?? 'view') { |
||
| 46 | case 'submit': |
||
| 47 | $title = 'Add User Role'; |
||
| 48 | $role = Role::create([ |
||
| 49 | 'name' => $request->input('name'), |
||
| 50 | 'apirequests' => $request->input('apirequests'), |
||
| 51 | 'downloadrequests' => $request->input('downloadrequests'), |
||
| 52 | 'defaultinvites' => $request->input('defaultinvites'), |
||
| 53 | 'donation' => $request->input('donation') ?? 0, |
||
| 54 | 'addyears' => $request->input('addyears') ?? 0, |
||
| 55 | 'rate_limit' => $request->input('rate_limit'), |
||
| 56 | ]); |
||
| 57 | if ((int) $request->input('canpreview') === 1) { |
||
| 58 | $role->givePermissionTo('preview'); |
||
| 59 | } |
||
| 60 | |||
| 61 | if ((int) $request->input('hideads') === 1) { |
||
| 62 | $role->givePermissionTo('hideads'); |
||
| 63 | } |
||
| 64 | |||
| 65 | if ((int) $request->input('editrelease') === 1) { |
||
| 66 | $role->givePermissionTo('edit release'); |
||
| 67 | } |
||
| 68 | |||
| 69 | if ((int) $request->input('viewconsole') === 1) { |
||
| 70 | $role->givePermissionTo('view console'); |
||
| 71 | } |
||
| 72 | |||
| 73 | if ((int) $request->input('viewmovies') === 1) { |
||
| 74 | $role->givePermissionTo('view movies'); |
||
| 75 | } |
||
| 76 | |||
| 77 | if ((int) $request->input('viewaudio') === 1) { |
||
| 78 | $role->givePermissionTo('view audio'); |
||
| 79 | } |
||
| 80 | |||
| 81 | if ((int) $request->input('viewpc') === 1) { |
||
| 82 | $role->givePermissionTo('view pc'); |
||
| 83 | } |
||
| 84 | |||
| 85 | if ((int) $request->input('viewtv') === 1) { |
||
| 86 | $role->givePermissionTo('view tv'); |
||
| 87 | } |
||
| 88 | |||
| 89 | if ((int) $request->input('viewadult') === 1) { |
||
| 90 | $role->givePermissionTo('view adult'); |
||
| 91 | } |
||
| 92 | |||
| 93 | if ((int) $request->input('viewbooks') === 1) { |
||
| 94 | $role->givePermissionTo('view books'); |
||
| 95 | } |
||
| 96 | |||
| 97 | if ((int) $request->input('viewother') === 1) { |
||
| 98 | $role->givePermissionTo('view other'); |
||
| 99 | } |
||
| 100 | redirect()->to('admin/role-list')->sendHeaders(); |
||
| 101 | break; |
||
| 102 | case 'view': |
||
| 103 | default: |
||
| 104 | $title = 'Add User Role'; |
||
| 105 | $role = [ |
||
| 106 | ]; |
||
| 107 | |||
| 108 | break; |
||
| 109 | } |
||
| 110 | |||
| 111 | $this->smarty->assign('yesno_ids', [1, 0]); |
||
| 112 | $this->smarty->assign('yesno_names', ['Yes', 'No']); |
||
| 113 | |||
| 114 | $content = $this->smarty->fetch('role-add.tpl'); |
||
| 115 | |||
| 116 | $this->smarty->assign( |
||
| 117 | [ |
||
| 118 | 'title' => $title, |
||
| 119 | 'meta_title' => $title, |
||
| 120 | 'content' => $content, |
||
| 121 | 'role' => $role, |
||
| 122 | ] |
||
| 123 | ); |
||
| 124 | |||
| 125 | $this->adminrender(); |
||
| 126 | } |
||
| 271 |
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.