Conditions | 11 |
Paths | 17 |
Total Lines | 70 |
Code Lines | 44 |
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 |
||
164 | public function acp_categories_config($id, $action, $mode) |
||
165 | { |
||
166 | $this->language->add_lang('acp/language'); |
||
167 | $form_key = 'sylver35/smiliescat'; |
||
168 | add_form_key($form_key); |
||
169 | |||
170 | if ($action) |
||
171 | { |
||
172 | if (in_array($action, ['config_cat', 'add_cat', 'edit_cat']) && !check_form_key($form_key)) |
||
173 | { |
||
174 | trigger_error($this->language->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); |
||
175 | } |
||
176 | |||
177 | switch ($action) |
||
178 | { |
||
179 | case 'config_cat': |
||
180 | $this->config->set('smilies_per_page_cat', (int) $this->request->variable('smilies_per_page_cat', 15)); |
||
181 | $this->config->set('smilies_per_page_acp', (int) $this->request->variable('smilies_per_page_acp', 15)); |
||
182 | |||
183 | $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_SC_CONFIG', time()); |
||
184 | trigger_error($this->language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action)); |
||
185 | break; |
||
186 | |||
187 | case 'add': |
||
188 | $this->work->add_cat($this->u_action); |
||
189 | break; |
||
190 | |||
191 | case 'add_cat': |
||
192 | $this->work->add_category($this->u_action); |
||
193 | break; |
||
194 | |||
195 | case 'edit': |
||
196 | $this->work->edit_cat((int) $id, $this->u_action); |
||
197 | break; |
||
198 | |||
199 | case 'edit_cat': |
||
200 | $this->work->edit_category((int) $id, $this->u_action); |
||
201 | break; |
||
202 | |||
203 | case 'delete': |
||
204 | if (confirm_box(true)) |
||
205 | { |
||
206 | $this->work->delete_cat((int) $id, $this->u_action); |
||
207 | } |
||
208 | else |
||
209 | { |
||
210 | confirm_box(false, $this->language->lang('CONFIRM_OPERATION'), build_hidden_fields([ |
||
211 | 'mode' => $mode, |
||
212 | 'id' => $id, |
||
213 | 'action' => $action, |
||
214 | ])); |
||
215 | } |
||
216 | break; |
||
217 | } |
||
218 | |||
219 | $this->template->assign_vars([ |
||
220 | 'IN_ACTION' => true, |
||
221 | ]); |
||
222 | } |
||
223 | else |
||
224 | { |
||
225 | $this->work->adm_list_cat($this->u_action); |
||
226 | } |
||
227 | |||
228 | $this->template->assign_vars([ |
||
229 | 'CATEGORIE_CONFIG' => true, |
||
230 | 'SMILIES_PER_PAGE_CAT' => $this->config['smilies_per_page_cat'], |
||
231 | 'SMILIES_PER_PAGE_ACP' => $this->config['smilies_per_page_acp'], |
||
232 | 'U_ACTION_CONFIG' => $this->u_action . '&action=config_cat', |
||
233 | 'U_ADD' => $this->u_action . '&action=add', |
||
234 | ]); |
||
249 |