SettingController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 1
cbo 7
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A index() 0 4 1
A getModuleSettings() 0 18 1
A store() 0 8 1
1
<?php namespace Modules\Setting\Http\Controllers\Admin;
2
3
use Illuminate\Session\Store;
4
use Modules\Core\Http\Controllers\Admin\AdminBaseController;
5
use Modules\Setting\Http\Requests\SettingRequest;
6
use Modules\Setting\Repositories\SettingRepository;
7
use Pingpong\Modules\Module;
8
9
class SettingController extends AdminBaseController
10
{
11
    /**
12
     * @var SettingRepository
13
     */
14
    private $setting;
15
    /**
16
     * @var Module
17
     */
18
    private $module;
19
    /**
20
     * @var Store
21
     */
22
    private $session;
23
24
    public function __construct(SettingRepository $setting, Store $session)
25
    {
26
        parent::__construct();
27
28
        $this->setting = $setting;
29
        $this->module = app('modules');
30
        $this->session = $session;
31
    }
32
33
    public function index()
34
    {
35
        return redirect()->route('dashboard.module.settings', ['core']);
36
    }
37
38
    public function store(SettingRequest $request)
39
    {
40
        $this->setting->createOrUpdate($request->all());
41
42
        flash(trans('setting::messages.settings saved'));
43
44
        return redirect()->route('dashboard.module.settings', [$this->session->get('module', 'Core')]);
45
    }
46
47
    public function getModuleSettings(Module $currentModule)
48
    {
49
        $this->assetPipeline->requireJs('selectize.js');
50
        $this->assetPipeline->requireCss('selectize.css');
51
        $this->assetPipeline->requireCss('selectize-default.css');
52
53
        $this->session->set('module', $currentModule->getLowerName());
54
55
        $modulesWithSettings = $this->setting->moduleSettings($this->module->enabled());
0 ignored issues
show
Documentation introduced by
$this->module->enabled() is of type boolean, but the function expects a array|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
56
57
        $translatableSettings = $this->setting->translatableModuleSettings($currentModule->getLowerName());
58
        $plainSettings = $this->setting->plainModuleSettings($currentModule->getLowerName());
59
60
        $dbSettings = $this->setting->savedModuleSettings($currentModule->getLowerName());
61
62
        return view('setting::admin.module-settings',
63
            compact('currentModule', 'translatableSettings', 'plainSettings', 'dbSettings', 'modulesWithSettings'));
64
    }
65
}
66