Passed
Push — master ( 81f334...c86e8c )
by Mihail
03:35
created

ActionSettings   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 73.33 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 22
loc 30
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
B settings() 22 22 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Apps\Controller\Admin\Main;
4
5
use Apps\Model\Admin\Main\FormSettings;
6
use Ffcms\Core\App;
7
use Ffcms\Core\Arch\View;
8
use Ffcms\Core\Network\Request;
9
use Ffcms\Core\Network\Response;
10
11
/**
12
 * Trait ActionSettings
13
 * @package Apps\Controller\Admin\Main
14
 * @property Request $request
15
 * @property Response $response
16
 * @property View $view
17
 */
18
trait ActionSettings
19
{
20
    /**
21
     * Manage settings in web
22
     * @return string
23
     * @throws \Ffcms\Core\Exception\SyntaxException
24
     */
25 View Code Duplication
    public function settings()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
26
    {
27
        // init settings model and process post send
28
        $model = new FormSettings(true);
29
        if ($model->send()) {
30
            if ($model->validate()) {
31
                if ($model->makeSave()) {
32
                    // show message about successful save and take system some time ;)
33
                    return $this->view->render('settings_save');
34
                } else {
35
                    App::$Session->getFlashBag()->add('error', __('Configuration file is not writable! Check /Private/Config/ dir and files'));
36
                }
37
            } else {
38
                App::$Session->getFlashBag()->add('error', __('Validation of form data is failed!'));
39
            }
40
        }
41
42
        // render output view
43
        return $this->view->render('settings', [
44
            'model' => $model
45
        ]);
46
    }
47
}
48