| Conditions | 9 |
| Paths | 8 |
| Total Lines | 67 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 9 | ||
| Bugs | 0 | Features | 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 |
||
| 94 | public function acp_smilies_category($id, $action) |
||
| 95 | { |
||
| 96 | $this->language->add_lang('acp/posting'); |
||
| 97 | $start = (int) $this->request->variable('start', 0); |
||
| 98 | $select = (int) $this->request->variable('select', 0); |
||
| 99 | $cat_id = (int) $this->request->variable('cat_id', 0); |
||
| 100 | $ex_cat = (int) $this->request->variable('ex_cat', 0); |
||
| 101 | $list = $this->request->variable('list', [0]); |
||
| 102 | $form_key = 'sylver35/smiliescat'; |
||
| 103 | add_form_key($form_key); |
||
| 104 | |||
| 105 | if ($action) |
||
| 106 | { |
||
| 107 | switch ($action) |
||
| 108 | { |
||
| 109 | case 'edit': |
||
| 110 | $this->smiley->edit_smiley($id, $start, $ex_cat, $this->u_action); |
||
| 111 | break; |
||
| 112 | |||
| 113 | case 'edit_multi': |
||
| 114 | $list = $this->request->variable('mark', [0]); |
||
| 115 | if (empty($list)) |
||
| 116 | { |
||
| 117 | trigger_error($this->language->lang('SC_SMILIES_EMPTY') . adm_back_link($this->u_action . '&start=' . $start . '#acp_smilies_category'), E_USER_WARNING); |
||
| 118 | } |
||
| 119 | |||
| 120 | $this->smiley->edit_multi_smiley($list, $start, $this->u_action); |
||
| 121 | break; |
||
| 122 | |||
| 123 | case 'modify': |
||
| 124 | if (!check_form_key($form_key)) |
||
| 125 | { |
||
| 126 | trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); |
||
| 127 | } |
||
| 128 | |||
| 129 | $this->smiley->modify_smiley($id, $cat_id, $ex_cat); |
||
| 130 | trigger_error($this->language->lang('SMILIES_EDITED', 1) . adm_back_link($this->u_action . '&start=' . $start . '#acp_smilies_category')); |
||
| 131 | break; |
||
| 132 | |||
| 133 | case 'modify_list': |
||
| 134 | foreach ($list as $smiley) |
||
| 135 | { |
||
| 136 | $this->smiley->modify_smiley($smiley, $cat_id); |
||
| 137 | } |
||
| 138 | |||
| 139 | trigger_error($this->language->lang('SMILIES_EDITED', count($list)) . adm_back_link($this->u_action . '&start=' . $start . '#acp_smilies_category')); |
||
| 140 | break; |
||
| 141 | } |
||
| 142 | |||
| 143 | $this->template->assign_vars([ |
||
| 144 | 'IN_ACTION' => true, |
||
| 145 | ]); |
||
| 146 | } |
||
| 147 | else |
||
| 148 | { |
||
| 149 | $this->smiley->extract_list_smilies($select, $start, $this->u_action); |
||
| 150 | |||
| 151 | $this->template->assign_vars([ |
||
| 152 | 'LIST_CATEGORY' => $this->smiley->select_categories($select, true, true), |
||
| 153 | 'U_SELECT_CAT' => $this->u_action . '&select=' . $select, |
||
| 154 | 'U_MODIFY_LIST' => $this->u_action . '&action=edit_multi&start=' . $start, |
||
| 155 | 'U_BACK' => $this->u_action, |
||
| 156 | ]); |
||
| 157 | } |
||
| 158 | |||
| 159 | $this->template->assign_vars([ |
||
| 160 | 'CATEGORIE_SMILIES' => true, |
||
| 161 | ]); |
||
| 249 |