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