| Conditions | 10 |
| Paths | 2 |
| Total Lines | 76 |
| Code Lines | 54 |
| 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 |
||
| 36 | public function edit(Request $request) |
||
| 37 | { |
||
| 38 | $this->setAdminPrefs(); |
||
| 39 | $binaries = new Binaries(['Settings' => null]); |
||
| 40 | $error = ''; |
||
| 41 | $regex = ['id' => '', 'groupname' => '', 'regex' => '', 'description' => '', 'msgcol' => 1, 'status' => 1, 'optype' => 1]; |
||
| 42 | $meta_title = $title = 'Binary Black/White list'; |
||
| 43 | |||
| 44 | switch ($request->input('action') ?? 'view') { |
||
| 45 | case 'submit': |
||
| 46 | if ($request->input('groupname') === '') { |
||
| 47 | $error = 'Group must be a valid usenet group'; |
||
| 48 | break; |
||
| 49 | } |
||
| 50 | |||
| 51 | if ($request->input('regex') === '') { |
||
| 52 | $error = 'Regex cannot be empty'; |
||
| 53 | break; |
||
| 54 | } |
||
| 55 | |||
| 56 | if (empty($request->input('id'))) { |
||
| 57 | $binaries->addBlacklist($request->all()); |
||
| 58 | } else { |
||
| 59 | $binaries->updateBlacklist($request->all()); |
||
| 60 | } |
||
| 61 | |||
| 62 | return redirect('admin/binaryblacklist-list'); |
||
| 63 | break; |
||
| 64 | |||
| 65 | case 'addtest': |
||
| 66 | if ($request->has('regex') && $request->has('groupname')) { |
||
| 67 | $regex += [ |
||
| 68 | 'groupname' => $request->input('groupname'), |
||
| 69 | 'regex' => $request->input('regex'), |
||
| 70 | 'ordinal' => 1, |
||
| 71 | 'status' => 1, |
||
| 72 | ]; |
||
| 73 | } |
||
| 74 | break; |
||
| 75 | |||
| 76 | case 'view': |
||
| 77 | default: |
||
| 78 | if ($request->has('id')) { |
||
| 79 | $title = 'Binary Black/Whitelist Edit'; |
||
| 80 | $regex = $binaries->getBlacklistByID($request->input('id')); |
||
| 81 | } else { |
||
| 82 | $title = 'Binary Black/Whitelist Add'; |
||
| 83 | $regex += [ |
||
| 84 | 'status' => 1, |
||
| 85 | 'optype' => 1, |
||
| 86 | 'msgcol' => 1, |
||
| 87 | ]; |
||
| 88 | } |
||
| 89 | break; |
||
| 90 | } |
||
| 91 | |||
| 92 | $this->smarty->assign( |
||
| 93 | [ |
||
| 94 | 'error' => $error, |
||
| 95 | 'regex' => $regex, |
||
| 96 | 'status_ids' => [Category::STATUS_ACTIVE, Category::STATUS_INACTIVE], |
||
| 97 | 'status_names' => ['Yes', 'No'], |
||
| 98 | 'optype_ids' => [1, 2], |
||
| 99 | 'optype_names' => ['Black', 'White'], |
||
| 100 | 'msgcol_ids' => [ |
||
| 101 | Binaries::BLACKLIST_FIELD_SUBJECT, |
||
| 102 | Binaries::BLACKLIST_FIELD_FROM, |
||
| 103 | Binaries::BLACKLIST_FIELD_MESSAGEID, |
||
| 104 | ], |
||
| 105 | 'msgcol_names' => ['Subject', 'Poster', 'MessageId'], |
||
| 106 | ] |
||
| 107 | ); |
||
| 108 | |||
| 109 | $content = $this->smarty->fetch('binaryblacklist-edit.tpl'); |
||
| 110 | $this->smarty->assign(compact('title', 'meta_title', 'content')); |
||
| 111 | $this->adminrender(); |
||
| 112 | } |
||
| 114 |
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.