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