GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AdminMenu::updateMenu()   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 90

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 90
rs 8.2181
c 0
b 0
f 0
cc 2
nc 2
nop 1

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
/*
3
  ÁTICA - Aplicación web para la gestión documental de centros educativos
4
5
  Copyright (C) 2015-2016: Luis Ramón López López
6
7
  This program is free software: you can redistribute it and/or modify
8
  it under the terms of the GNU Affero General Public License as published by
9
  the Free Software Foundation, either version 3 of the License, or
10
  (at your option) any later version.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU Affero General Public License for more details.
16
17
  You should have received a copy of the GNU Affero General Public License
18
  along with this program.  If not, see [http://www.gnu.org/licenses/].
19
*/
20
21
namespace AppBundle\Service;
22
23
use AppBundle\Menu\MenuItem;
24
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
25
26
class AdminMenu implements MenuBuilderInterface
27
{
28
    private $authorizationChecker;
29
30
    public function __construct(AuthorizationChecker $authorizationChecker)
31
    {
32
        $this->authorizationChecker = $authorizationChecker;
33
    }
34
35
    public function updateMenu(&$menu)
36
    {
37
        $isAdministrator = $this->authorizationChecker->isGranted("ROLE_ADMIN");
38
39
        if (!$isAdministrator) {
40
            return null;
41
        }
42
43
        /**
44
         * @var $root MenuItem
45
         */
46
        $root = reset($menu);
47
48
        $mainItem = new MenuItem();
49
        $mainItem
50
            ->setName('admin')
51
            ->setRouteName('admin_menu')
52
            ->setCaption('menu.admin')
53
            ->setDescription('menu.admin.detail')
54
            ->setColor('teal')
55
            ->setIcon('wrench');
56
57
        $item = new MenuItem();
58
        $item
59
            ->setName('admin.users')
60
            ->setRouteName('admin_users')
61
            ->setCaption('menu.admin.manage.users')
62
            ->setDescription('menu.admin.manage.users.detail')
63
            ->setColor('amber')
64
            ->setIcon('id-badge');
65
66
        $mainItem->addChild($item);
67
68
        $item = new MenuItem();
69
        $item
70
            ->setName('admin.departments')
71
            ->setRouteName('admin_department')
72
            ->setCaption('menu.admin.departments')
73
            ->setDescription('menu.admin.departments.detail')
74
            ->setColor('yellow')
75
            ->setIcon('sitemap');
76
77
        $mainItem->addChild($item);
78
79
        $item = new MenuItem();
80
        $item
81
            ->setName('admin.trainings')
82
            ->setRouteName('admin_training')
83
            ->setCaption('menu.admin.trainings')
84
            ->setDescription('menu.admin.trainings.detail')
85
            ->setColor('green')
86
            ->setIcon('bank');
87
88
        $mainItem->addChild($item);
89
90
        $item = new MenuItem();
91
        $item
92
            ->setName('admin.groups')
93
            ->setRouteName('admin_group')
94
            ->setCaption('menu.admin.groups')
95
            ->setDescription('menu.admin.groups.detail')
96
            ->setColor('emerald')
97
            ->setIcon('users');
98
99
        $mainItem->addChild($item);
100
        
101
        $item = new MenuItem();
102
        $item
103
            ->setName('admin.programs')
104
            ->setRouteName('admin_program')
105
            ->setCaption('menu.admin.programs')
106
            ->setDescription('menu.admin.programs.detail')
107
            ->setColor('red')
108
            ->setIcon('book');
109
110
        $mainItem->addChild($item);
111
112
        $item = new MenuItem();
113
        $item
114
            ->setName('admin.calendar')
115
            ->setRouteName('admin_non_school_day')
116
            ->setCaption('menu.admin.calendar')
117
            ->setDescription('menu.admin.calendar.detail')
118
            ->setColor('dark-teal')
119
            ->setIcon('calendar-times-o');
120
121
        $mainItem->addChild($item);
122
123
        $root->addChild($mainItem, MenuItem::AT_THE_END);
124
    }
125
126
    public function getMenuPriority()
127
    {
128
        return '1000-Admin';
129
    }
130
}
131