Completed
Push — master ( 58fb5e...df6768 )
by Fèvre
14s
created

MenuServiceProvider::boot()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 80
Code Lines 59

Duplication

Lines 72
Ratio 90 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 72
loc 80
rs 8.8387
c 1
b 0
f 0
cc 1
eloc 59
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
namespace Xetaravel\Providers;
3
4
use Illuminate\Support\ServiceProvider;
5
use Spatie\Menu\Laravel\MenuFacade as Menu;
6
use Spatie\Menu\Laravel\Link;
7
8
class MenuServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any application services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17 View Code Duplication
        Menu::macro('user.profile', function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
18
            return Menu::new()
19
                ->addClass('nav nav-menu flex-column')
20
                ->setAttribute('role', 'navigation')
21
                ->add(
22
                    Link::toRoute('users.account.index', '<i class="fa fa-user"></i> Account')
23
                        ->addClass('nav-link')
24
                )
25
                ->add(
26
                    Link::toRoute('users.notification.index', '<i class="fa fa-bell-o"></i> Notifications')
27
                        ->addClass('nav-link')
28
                )
29
                ->add(
30
                    Link::toRoute('users.user.settings', '<i class="fa fa-cogs"></i> Settings')
31
                        ->addClass('nav-link')
32
                )
33
                ->setActiveFromRequest();
34
        });
35
36
        // Administration
37 View Code Duplication
        Menu::macro('admin.administration', function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
38
            return Menu::new()
39
                ->addClass('nav nav-pills flex-column mb-0')
40
                ->setAttribute('role', 'navigation')
41
                ->add(
42
                    Link::toRoute('admin.page.index', '<i class="fa fa-dashboard"></i> Dashboard')
43
                        ->addClass('nav-link')
44
                        ->addParentClass('nav-item')
45
                )
46
                ->setActiveFromRequest('/admin');
47
        });
48
49 View Code Duplication
        Menu::macro('admin.blog', function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
50
            return Menu::new()
51
                ->addClass('nav nav-pills flex-column mb-0')
52
                ->setAttribute('role', 'navigation')
53
                ->add(
54
                    Link::toRoute('admin.blog.article.index', '<i class="fa fa-newspaper-o"></i> Manage Articles')
55
                        ->addClass('nav-link')
56
                        ->addParentClass('nav-item')
57
                )
58
                ->add(
59
                    Link::toRoute('admin.blog.category.index', '<i class="fa fa-tags"></i> Manage Categories')
60
                        ->addClass('nav-link')
61
                        ->addParentClass('nav-item')
62
                )
63
                ->setActiveFromRequest();
64
        });
65
66 View Code Duplication
        Menu::macro('admin.user', function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
67
            return Menu::new()
68
                ->addClass('nav nav-pills flex-column mb-0')
69
                ->setAttribute('role', 'navigation')
70
                ->add(
71
                    Link::toRoute('admin.user.user.index', '<i class="fa fa-users"></i> Manage Users')
72
                        ->addClass('nav-link')
73
                        ->addParentClass('nav-item')
74
                )
75
                ->setActiveFromRequest();
76
        });
77
78 View Code Duplication
        Menu::macro('admin.role', function () {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
79
            return Menu::new()
80
                ->addClass('nav nav-pills flex-column mb-0')
81
                ->setAttribute('role', 'navigation')
82
                ->add(
83
                    Link::toRoute('admin.role.role.index', '<i class="fa fa-user-circle-o"></i> Manage Roles')
84
                        ->addClass('nav-link')
85
                        ->addParentClass('nav-item')
86
                )
87
                ->add(
88
                    Link::toRoute('admin.role.permission.index', '<i class="fa fa-wrench"></i> Manage Permissions')
89
                        ->addClass('nav-link')
90
                        ->addParentClass('nav-item')
91
                )
92
                ->setActiveFromRequest();
93
        });
94
    }
95
}
96