SettingsController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
c 2
b 1
f 0
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Terranet\Administrator\Controllers;
4
5
use Illuminate\Support\Arr;
6
use Terranet\Administrator\AdminRequest;
7
use Terranet\Administrator\Architect;
8
use Terranet\Administrator\Requests\UpdateRequest;
9
10
class SettingsController extends AdminController
11
{
12
    /**
13
     * List settings by selected group [according to settings page name].
14
     *
15
     * @return $this
16
     */
17
    public function edit(AdminRequest $request)
18
    {
19
        $resource = $request->resource();
20
        $this->authorize('index', $eloquent = $resource->model());
21
22
        return view(Architect::template()->layout('settings'), [
0 ignored issues
show
Bug introduced by
The function view was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        return /** @scrutinizer ignore-call */ view(Architect::template()->layout('settings'), [
Loading history...
23
            'settings' => options_fetch(),
0 ignored issues
show
Bug introduced by
The function options_fetch was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            'settings' => /** @scrutinizer ignore-call */ options_fetch(),
Loading history...
24
            'resource' => $resource,
25
        ]);
26
    }
27
28
    /**
29
     * Save settings per page.
30
     *
31
     * @param  UpdateRequest  $request
32
     * @return \Illuminate\Http\RedirectResponse
33
     */
34
    public function update(AdminRequest $request)
35
    {
36
        $resource = $request->resource();
37
        $this->authorize('update', $eloquent = $resource->model());
38
39
        options_save(Arr::except(
0 ignored issues
show
Bug introduced by
The function options_save was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
        /** @scrutinizer ignore-call */ 
40
        options_save(Arr::except(
Loading history...
40
            $request->all(),
41
            ['_token', 'save']
42
        ));
43
44
        return back()->with('messages', ['Settings saved successfully']);
0 ignored issues
show
Bug introduced by
The function back was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

44
        return /** @scrutinizer ignore-call */ back()->with('messages', ['Settings saved successfully']);
Loading history...
45
    }
46
47
    /**
48
     * @param  AdminRequest  $request
49
     * @return $this
50
     */
51
    public function index(AdminRequest $request)
52
    {
53
        $resource = $request->resource();
54
        $this->authorize('index', $eloquent = $resource->model());
55
56
        return $this->edit();
0 ignored issues
show
Bug introduced by
The call to Terranet\Administrator\C...tingsController::edit() has too few arguments starting with request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
        return $this->/** @scrutinizer ignore-call */ edit();

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
57
    }
58
}
59