SidebarExtender   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 64
Duplicated Lines 42.19 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 2
c 3
b 0
f 1
lcom 1
cbo 0
dl 27
loc 64
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
B extendWith() 27 41 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 namespace Modules\Blog\Sidebar;
2
3
use Maatwebsite\Sidebar\Group;
4
use Maatwebsite\Sidebar\Item;
5
use Maatwebsite\Sidebar\Menu;
6
use Modules\Core\Contracts\Authentication;
7
8
class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender
9
{
10
    /**
11
     * @var Authentication
12
     */
13
    protected $auth;
14
15
    /**
16
     * @param Authentication $auth
17
     *
18
     * @internal param Guard $guard
19
     */
20
    public function __construct(Authentication $auth)
21
    {
22
        $this->auth = $auth;
23
    }
24
25
    /**
26
     * @param Menu $menu
27
     *
28
     * @return Menu
29
     */
30
    public function extendWith(Menu $menu)
31
    {
32
        $menu->group(trans('core::sidebar.content'), function (Group $group) {
33
            $group->item(trans('blog::blog.title'), function (Item $item) {
34
35
                $item->icon('fa fa-copy');
36
                $item->weight(0);
37
38 View Code Duplication
                $item->item(trans('blog::post.title.post'), function (Item $item) {
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...
39
                    $item->icon('fa fa-copy');
40
                    $item->weight(0);
41
                    $item->append('admin.blog.post.create');
42
                    $item->route('admin.blog.post.index');
43
                    $item->authorize(
44
                        $this->auth->hasAccess('blog.posts.index')
45
                    );
46
                });
47 View Code Duplication
                $item->item(trans('blog::tag.title.tag'), function (Item $item) {
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...
48
                    $item->icon('fa fa-tags');
49
                    $item->weight(0);
50
                    $item->append('admin.blog.tag.create');
51
                    $item->route('admin.blog.tag.index');
52
                    $item->authorize(
53
                        $this->auth->hasAccess('blog.tags.index')
54
                    );
55
                });
56 View Code Duplication
                $item->item(trans('blog::category.title.category'), function (Item $item) {
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...
57
                    $item->icon('fa fa-file-text');
58
                    $item->weight(1);
59
                    $item->route('admin.blog.category.index');
60
                    $item->append('admin.blog.category.create');
61
                    $item->authorize(
62
                        $this->auth->hasAccess('blog.categories.index')
63
                    );
64
                });
65
66
            });
67
        });
68
69
        return $menu;
70
    }
71
}
72