MenuConfig::menu()   B
last analyzed

Complexity

Conditions 6
Paths 8

Size

Total Lines 126
Code Lines 69

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 69
c 2
b 0
f 0
dl 0
loc 126
ccs 9
cts 9
cp 1
rs 8.0541
cc 6
nc 8
nop 2
crap 6

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 namespace Distilleries\Expendable\Config;
2
3
class MenuConfig {
4
5 288
    public static function menu($merge = [], $direction = 'end')
6
    {
7
8
        $first = [
9 144
            'left'  => [
10
                [
11
                    'icon'    => 'user',
12
                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\UserController@getIndex',
13
                    'libelle' => 'expendable::menu.user',
14
                    'submenu' => [
15
                        [
16
                            'icon'    => 'th-list',
17
                            'libelle' => 'expendable::menu.list',
18
                            'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\UserController@getIndex',
19
                        ],
20
                        [
21
                            'icon'    => 'pencil',
22
                            'libelle' => 'expendable::menu.add_state',
23
                            'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\UserController@getEdit',
24
                        ],
25
                        [
26
                            'icon'    => 'barcode',
27
                            'libelle' => 'expendable::menu.my_profile',
28
                            'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\UserController@getProfile',
29
                        ],
30
                    ],
31
                ],
32
                [
33
                    'icon'    => 'cog',
34
                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\RoleController@getIndex',
35
                    'libelle' => 'expendable::menu.administration',
36
                    'submenu' => [
37
                        [
38
                            'icon'    => 'certificate',
39
                            'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\RoleController@getIndex',
40
                            'libelle' => 'expendable::menu.role',
41
                            'submenu' => [
42
                                [
43
                                    'icon'    => 'th-list',
44
                                    'libelle' => 'expendable::menu.list',
45
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\RoleController@getIndex',
46
                                ],
47
                                [
48
                                    'icon'    => 'pencil',
49
                                    'libelle' => 'expendable::menu.add_state',
50
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\RoleController@getEdit',
51
                                ],
52
                            ],
53
                        ],
54
                        [
55
                            'icon'    => 'wrench',
56
                            'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\PermissionController@getIndex',
57
                            'libelle' => 'expendable::menu.permission',
58
                            'submenu' => [
59
                                [
60
                                    'icon'    => 'th-list',
61
                                    'libelle' => 'expendable::menu.list',
62
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\ServiceController@getIndex',
63
                                ],
64
                                [
65
                                    'icon'    => 'pencil',
66
                                    'libelle' => 'expendable::menu.add_state',
67
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\ServiceController@getEdit',
68
                                ],
69
                                [
70
                                    'icon'    => 'refresh',
71
                                    'libelle' => 'expendable::menu.sync_service',
72
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\ServiceController@getSynchronize',
73
                                ],
74
                                [
75
                                    'icon'    => 'ok-circle',
76
                                    'libelle' => 'expendable::menu.associate_permission',
77
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\PermissionController@getIndex',
78
                                ],
79
                            ],
80
                        ],
81
                        [
82
                            'icon'    => 'flag',
83
                            'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\LanguageController@getIndex',
84
                            'libelle' => 'expendable::menu.language',
85
                            'submenu' => [
86
                                [
87
                                    'icon'    => 'th-list',
88
                                    'libelle' => 'expendable::menu.list',
89
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\LanguageController@getIndex',
90
                                ],
91
                                [
92
                                    'icon'    => 'pencil',
93
                                    'libelle' => 'expendable::menu.add_state',
94
                                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\LanguageController@getEdit',
95
                                ],
96
                            ],
97
                        ],
98
                    ]
99
                ],
100 144
            ],
101
102
            'tasks' => [
103
                [
104
                    'icon'    => 'console',
105
                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\ComponentController@getIndex',
106
                    'libelle' => 'expendable::menu.generate_component',
107
108
                ],
109
                [
110
                    'icon'    => 'retweet',
111
                    'action'  => '\Distilleries\Expendable\Http\Controllers\Backend\ServiceController@getSynchronize',
112
                    'libelle' => 'expendable::menu.sync_service',
113
114
                ],
115
            ]
116
        ];
117
118
119 288
        if ($direction == 'end')
120
        {
121 2
            $first['left']  = !empty($merge['left']) ? array_merge($first['left'], $merge['left']) : $first['left'];
122 2
            $first['tasks'] = !empty($merge['tasks']) ? array_merge($first['tasks'], $merge['tasks']) : $first['tasks'];
123
        } else
124
        {
125 288
            $first['left']  = !empty($merge['left']) ? array_merge($merge['left'], $first['left']) : $first['left'];
126 288
            $first['tasks'] = !empty($merge['tasks']) ? array_merge($merge['tasks'], $first['tasks']) : $first['tasks'];
127
        }
128
129
130 288
        return $first;
131
    }
132
}