| Conditions | 20 |
| Paths | 18432 |
| Total Lines | 49 |
| 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 |
||
| 78 | function formAction() |
||
| 79 | { |
||
| 80 | global $tpl, $translate; |
||
| 81 | |||
| 82 | $commit = isset($_REQUEST['chkcommit']) ? $_REQUEST['chkcommit'] + 0 : 0; |
||
| 83 | $delete = isset($_REQUEST['chkdelete']) ? $_REQUEST['chkdelete'] + 0 : 0; |
||
| 84 | $deleteGdpr = isset($_REQUEST['chkdeletegdpr']) ? $_REQUEST['chkdeletegdpr'] + 0 : 0; |
||
| 85 | $disable = isset($_REQUEST['chkdisable']) ? $_REQUEST['chkdisable'] + 0 : 0; |
||
| 86 | $emailProblem = isset($_REQUEST['chkemail']) ? $_REQUEST['chkemail'] + 0 : 0; |
||
| 87 | $dataLicense = isset($_REQUEST['chkdl']) ? true : false; |
||
| 88 | $userId = isset($_REQUEST['userid']) ? $_REQUEST['userid'] + 0 : 0; |
||
| 89 | $disduelicense = isset($_REQUEST['chkdisduelicense']) ? $_REQUEST['chkdisduelicense'] + 0 : 0; |
||
| 90 | |||
| 91 | $user = new user($userId); |
||
| 92 | if ($user->exist() === false) { |
||
| 93 | $tpl->error(ERROR_UNKNOWN); |
||
| 94 | } |
||
| 95 | $username = $user->getUsername(); |
||
| 96 | |||
| 97 | if ($delete + $disable + $disduelicense + $deleteGdpr > 1) { |
||
| 98 | $tpl->error($translate->t('Please select only one of the delete/disable options!', '', '', 0)); |
||
| 99 | } |
||
| 100 | |||
| 101 | if ($commit == 0) { |
||
| 102 | $tpl->error($translate->t('You have to check that you are sure!', '', '', 0)); |
||
| 103 | } |
||
| 104 | |||
| 105 | if ($disduelicense == 1) { |
||
| 106 | $errorMessage = $user->disduelicense(); |
||
| 107 | if ($errorMessage !== true) { |
||
| 108 | $tpl->error($errorMessage); |
||
| 109 | } |
||
| 110 | } elseif ($disable == 1) { |
||
| 111 | if ($user->disable() == false) { |
||
|
|
|||
| 112 | $tpl->error(ERROR_UNKNOWN); |
||
| 113 | } |
||
| 114 | } elseif ($delete == 1) { |
||
| 115 | if ($user->delete() == false) { |
||
| 116 | $tpl->error(ERROR_UNKNOWN); |
||
| 117 | } |
||
| 118 | } elseif ($deleteGdpr == 1) { |
||
| 119 | $tpl->redirect('adminuser.php?action=gdpr-deletion&userid=' . $userId); |
||
| 120 | } elseif ($emailProblem == 1) { |
||
| 121 | $user->addEmailProblem($dataLicense); |
||
| 122 | } |
||
| 123 | |||
| 124 | $tpl->redirect('adminuser.php?action=searchuser&username=' . urlencode($username) . |
||
| 125 | '&success=' . ($disduelicense + $disable)); |
||
| 126 | } |
||
| 127 | |||
| 203 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.