Completed
Pull Request — master (#21)
by Fèvre
06:31 queued 03:41
created

MenuServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 88
Duplicated Lines 81.82 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 72
loc 88
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B boot() 72 80 1

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
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