Test Failed
Push — master ( bbc207...52bda4 )
by Terzi
05:51
created

AdminServiceProvider::withSettings()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 12
rs 10
1
<?php
2
3
namespace App\Providers;
4
5
use App\Http\Terranet\Administrator\Dashboard\BlankPanel;
6
use App\Http\Terranet\Administrator\Dashboard\DatabasePanel;
7
use App\Http\Terranet\Administrator\Dashboard\MembersPanel;
8
use Illuminate\Support\ServiceProvider;
9
use Pingpong\Menus\Menu;
10
use Pingpong\Menus\MenuBuilder;
11
use Pingpong\Menus\MenuItem;
12
use Terranet\Administrator\Architect;
13
use Terranet\Administrator\Contracts\Module\Navigable;
14
use Terranet\Administrator\Dashboard\Manager;
15
use Terranet\Administrator\Dashboard\Row;
16
use Terranet\Options\Manager as OptionsManager;
0 ignored issues
show
Bug introduced by
The type Terranet\Options\Manager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
18
class AdminServiceProvider extends ServiceProvider
19
{
20
    /**
21
     * Dashboard panels registration.
22
     *
23
     * @param  Manager  $dashboard
24
     * @return Manager
25
     */
26
    protected function dashboard(Manager $dashboard)
27
    {
28
        return $dashboard
29
            ->row(static function (Row $row) {
30
                $row->panel(new BlankPanel())->setWidth(12);
31
            })
32
            ->row(static function (Row $row) {
33
                $row->panel(new MembersPanel())->setWidth(6);
34
                $row->panel(new DatabasePanel())->setWidth(6);
35
            });
36
    }
37
38
    /**
39
     * @param  Menu  $navigation
40
     * @return Menu
41
     */
42
    protected function navigation(Menu $navigation)
43
    {
44
        $this->initSidebar($navigation)
45
            ->initToolbar($navigation);
46
47
        return $navigation;
48
    }
49
50
    /**
51
     * Register services.
52
     *
53
     * @return void
54
     */
55
    public function register()
56
    {
57
        $this->app->singleton('scaffold.dashboard', function () {
58
            return $this->dashboard(new Manager());
59
        });
60
61
        $this->app->singleton('scaffold.navigation', function ($app) {
62
            return $this->navigation(new Menu($app['view'], $app['config']));
63
        });
64
    }
65
66
    /**
67
     * Bootstrap any application services.
68
     *
69
     * @return void
70
     */
71
    public function boot()
72
    {
73
        $this->routes();
74
    }
75
76
    /**
77
     * Register AdminArchitect routes.
78
     */
79
    protected function routes()
80
    {
81
        Architect::routes()
82
            ->withAuthenticationRoutes()
83
            ->withTranslationRoutes()
84
            ->withMediaRoutes()
85
            ->withSettingRoutes()
86
            ->withExtraRoutes(function () {
87
                $path = base_path('routes/admin.php');
0 ignored issues
show
Bug introduced by
The function base_path 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

87
                $path = /** @scrutinizer ignore-call */ base_path('routes/admin.php');
Loading history...
88
89
                if (file_exists($path)) {
90
                    $this->loadRoutesFrom($path);
91
                }
92
            });
93
    }
94
95
    /**
96
     * @param  Menu  $navigation
97
     * @return AdminServiceProvider
98
     */
99
    protected function initSidebar(Menu $navigation): self
100
    {
101
        $navigation->create(Navigable::MENU_SIDEBAR, static function (MenuBuilder $sidebar) {
102
            $this->withDashboard($sidebar);
103
104
            // Create "resources" group
105
            $sidebar->dropdown(trans('administrator::module.groups.resources'), static function (MenuItem $sub) {
0 ignored issues
show
Unused Code introduced by
The parameter $sub is not used and could be removed. ( Ignorable by Annotation )

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

105
            $sidebar->dropdown(trans('administrator::module.groups.resources'), static function (/** @scrutinizer ignore-unused */ MenuItem $sub) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Bug introduced by
The function trans 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

105
            $sidebar->dropdown(/** @scrutinizer ignore-call */ trans('administrator::module.groups.resources'), static function (MenuItem $sub) {
Loading history...
106
                // $sub->route();
107
            }, 2, ['id' => 'groups', 'icon' => 'fa fa-qrcode']);
108
        });
109
110
        return $this;
111
    }
112
113
    /**
114
     * @param  Menu  $navigation
115
     * @return AdminServiceProvider
116
     */
117
    protected function initToolbar(Menu $navigation): self
118
    {
119
        $navigation->create(Navigable::MENU_TOOLS, function (MenuBuilder $tools) {
120
            $this->withMedia($tools)
121
                ->withSettings($tools)
122
                ->withTranslations($tools);
123
124
            $tools->url(
125
                route('scaffold.logout'),
0 ignored issues
show
Bug introduced by
The function route 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

125
                /** @scrutinizer ignore-call */ 
126
                route('scaffold.logout'),
Loading history...
126
                trans('administrator::buttons.logout'),
0 ignored issues
show
Bug introduced by
The function trans 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

126
                /** @scrutinizer ignore-call */ 
127
                trans('administrator::buttons.logout'),
Loading history...
127
                100,
128
                ['icon' => 'fa fa-mail-forward']
129
            );
130
        });
131
132
        return $this;
133
    }
134
135
    /**
136
     * @param  MenuBuilder  $sidebar
137
     * @return $this
138
     */
139
    public function withDashboard(MenuBuilder $sidebar): self
140
    {
141
        $sidebar->route('scaffold.dashboard', trans('administrator::module.dashboard'), [], 1, [
0 ignored issues
show
Bug introduced by
The function trans 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

141
        $sidebar->route('scaffold.dashboard', /** @scrutinizer ignore-call */ trans('administrator::module.dashboard'), [], 1, [
Loading history...
142
            'id' => 'dashboard',
143
            'icon' => 'fa fa-home',
144
            'active' => str_is(request()->route()->getName(), 'scaffold.dashboard'),
0 ignored issues
show
Deprecated Code introduced by
The function str_is() has been deprecated: Str::is() should be used directly instead. Will be removed in Laravel 5.9. ( Ignorable by Annotation )

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

144
            'active' => /** @scrutinizer ignore-deprecated */ str_is(request()->route()->getName(), 'scaffold.dashboard'),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Bug introduced by
The function request 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

144
            'active' => str_is(/** @scrutinizer ignore-call */ request()->route()->getName(), 'scaffold.dashboard'),
Loading history...
145
        ]);
146
147
        return $this;
148
    }
149
150
    /**
151
     * @param  MenuBuilder  $tools
152
     * @return $this
153
     */
154
    protected function withMedia(MenuBuilder $tools): self
155
    {
156
        if (config('administrator.file_manager.enabled')) {
0 ignored issues
show
Bug introduced by
The function config 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

156
        if (/** @scrutinizer ignore-call */ config('administrator.file_manager.enabled')) {
Loading history...
157
            $tools->url(
158
                route('scaffold.media'),
0 ignored issues
show
Bug introduced by
The function route 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

158
                /** @scrutinizer ignore-call */ 
159
                route('scaffold.media'),
Loading history...
159
                trans('administrator::buttons.media'),
0 ignored issues
show
Bug introduced by
The function trans 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

159
                /** @scrutinizer ignore-call */ 
160
                trans('administrator::buttons.media'),
Loading history...
160
                1,
161
                ['icon' => 'fa fa-file-text-o']
162
            );
163
        }
164
165
        return $this;
166
    }
167
168
    /**
169
     * @param  MenuBuilder  $tools
170
     * @return $this
171
     */
172
    protected function withSettings(MenuBuilder $tools): self
173
    {
174
        if (config('administrator.settings.enabled') && class_exists(OptionsManager::class, true)) {
0 ignored issues
show
Bug introduced by
The function config 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

174
        if (/** @scrutinizer ignore-call */ config('administrator.settings.enabled') && class_exists(OptionsManager::class, true)) {
Loading history...
175
            $tools->url(
176
                route('scaffold.settings.edit'),
0 ignored issues
show
Bug introduced by
The function route 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

176
                /** @scrutinizer ignore-call */ 
177
                route('scaffold.settings.edit'),
Loading history...
177
                trans('administrator::module.resources.settings'),
0 ignored issues
show
Bug introduced by
The function trans 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

177
                /** @scrutinizer ignore-call */ 
178
                trans('administrator::module.resources.settings'),
Loading history...
178
                2,
179
                ['icon' => 'fa fa-gears']
180
            );
181
        }
182
183
        return $this;
184
    }
185
186
    /**
187
     * @param  MenuBuilder  $tools
188
     * @return $this
189
     */
190
    protected function withTranslations(MenuBuilder $tools): self
191
    {
192
        if (config('administrator.translations.enabled')) {
0 ignored issues
show
Bug introduced by
The function config 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

192
        if (/** @scrutinizer ignore-call */ config('administrator.translations.enabled')) {
Loading history...
193
            $tools->url(
194
                route('scaffold.translations.index'),
0 ignored issues
show
Bug introduced by
The function route 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

194
                /** @scrutinizer ignore-call */ 
195
                route('scaffold.translations.index'),
Loading history...
195
                trans('administrator::buttons.translations'),
0 ignored issues
show
Bug introduced by
The function trans 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

195
                /** @scrutinizer ignore-call */ 
196
                trans('administrator::buttons.translations'),
Loading history...
196
                3,
197
                ['icon' => 'fa fa-globe']
198
            );
199
        }
200
201
        return $this;
202
    }
203
}
204