Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 22 |
Ratio | 100 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
20 | View Code Duplication | public function actionIndex() |
|
|
|||
21 | { |
||
22 | // initialize model and pass configs inside |
||
23 | $model = new FormSettings($this->getConfigs()); |
||
24 | |||
25 | // check if submit request is sended |
||
26 | if ($model->send()) { |
||
27 | if ($model->validate()) { |
||
28 | // save configurations |
||
29 | $this->setConfigs($model->getAllProperties()); |
||
30 | App::$Session->getFlashBag()->add('success', __('Settings is successful updated')); |
||
31 | App::$Response->redirect('search/index'); |
||
32 | } else { |
||
33 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
||
34 | } |
||
35 | } |
||
36 | |||
37 | // render output view |
||
38 | return App::$View->render('settings', [ |
||
39 | 'model' => $model->filter() |
||
40 | ]); |
||
41 | } |
||
42 | |||
43 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.