AdminDataMenuBuilder::dataMenu()   D
last analyzed

Complexity

Conditions 10
Paths 512

Size

Total Lines 98
Code Lines 57

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 10
eloc 57
nc 512
nop 1
dl 0
loc 98
rs 4.2804
c 1
b 0
f 0

How to fix   Long Method    Complexity   

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
namespace App\Menu;
4
5
use App\Security\Voter\ExamVoter;
6
use Knp\Menu\ItemInterface;
7
8
class AdminDataMenuBuilder extends AbstractMenuBuilder {
9
    public function dataMenu(array $options = []): ItemInterface {
0 ignored issues
show
Unused Code introduced by
The parameter $options 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

9
    public function dataMenu(/** @scrutinizer ignore-unused */ array $options = []): ItemInterface {

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...
10
        $root = $this->factory->createItem('root');
11
12
        if($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
13
            $root->addChild('admin.sections.label', [
14
                'route' => 'admin_sections'
15
            ])
16
                ->setExtra('icon', 'fas fa-sliders-h');
17
        }
18
19
        if($this->authorizationChecker->isGranted('ROLE_DOCUMENTS_ADMIN')) {
20
            $root->addChild('admin.documents.label', [
21
                'route' => 'admin_documents'
22
            ])
23
                ->setExtra('icon', 'fas fa-file-alt');
24
        }
25
26
        if($this->authorizationChecker->isGranted('ROLE_MESSAGE_CREATOR')) {
27
            $root->addChild('admin.messages.label', [
28
                'route' => 'admin_messages'
29
            ])
30
                ->setExtra('icon', 'fas fa-envelope-open-text');
31
        }
32
33
        if($this->authorizationChecker->isGranted(ExamVoter::Manage)) {
34
            $root->addChild('admin.exams.label', [
35
                'route' => 'admin_exams'
36
            ])
37
                ->setExtra('icon', 'fas fa-pen');
38
        }
39
40
        if($this->authorizationChecker->isGranted('ROLE_APPOINTMENT_CREATOR')) {
41
            $root->addChild('admin.appointments.label', [
42
                'route' => 'admin_appointments'
43
            ])
44
                ->setExtra('icon', 'far fa-calendar');
45
        }
46
47
        if($this->authorizationChecker->isGranted('ROLE_WIKI_ADMIN')) {
48
            $root->addChild('admin.wiki.label', [
49
                'route' => 'admin_wiki'
50
            ])
51
                ->setExtra('icon', 'fab fa-wikipedia-w');
52
        }
53
54
        if($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
55
            $root->addChild('admin.timetable.label', [
56
                'route' => 'admin_timetable'
57
            ])
58
                ->setExtra('icon', 'far fa-clock');
59
60
            $root->addChild('admin.resources.label', [
61
                'route' => 'admin_resources'
62
            ])
63
                ->setExtra('icon', 'fas fa-laptop-house');
64
65
            $root->addChild('admin.teachers.label', [
66
                'route' => 'admin_teachers'
67
            ])
68
                ->setExtra('icon', 'fas fa-sort-alpha-down');
69
70
            $root->addChild('admin.absence_types.label_students', [
71
                'route' => 'admin_absence_types'
72
            ])
73
                ->setExtra('icon', 'fas fa-user-times');
74
75
            $root->addChild('admin.absence_types.label_teachers', [
76
                'route' => 'admin_teacher_absence_types'
77
            ])
78
                ->setExtra('icon', 'fas fa-user-times');
79
        }
80
81
        if($this->authorizationChecker->isGranted('ROLE_ADMIN')) {
82
            $root->addChild('admin.subjects.label', [
83
                'route' => 'admin_subjects'
84
            ])
85
                ->setExtra('icon', 'fas fa-graduation-cap');
86
87
            $root->addChild('admin.displays.label', [
88
                'route' => 'admin_displays'
89
            ])
90
                ->setExtra('icon', 'fas fa-tv');
91
92
            $root->addChild('admin.tuition_grades.label', [
93
                'route' => 'admin_tuition_grades'
94
            ])
95
                ->setExtra('icon', 'fas fa-user-graduate');
96
        }
97
98
        if($this->authorizationChecker->isGranted('ROLE_SUPER_ADMIN')) {
99
            $root->addChild('admin.ea.label', [
100
                'uri' => '/admin/ea'
101
            ])
102
                ->setLinkAttribute('target', '_blank')
103
                ->setExtra('icon', 'fas fa-tools');
104
        }
105
106
        return $root;
107
    }
108
}