Passed
Push — master ( 326215...afdb28 )
by Alexey
03:20
created

Bootstrap::bootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 54
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 54
rs 9.6716
cc 1
eloc 32
nc 1
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
namespace modules\rbac;
3
4
use Yii;
5
6
/**
7
 * Class Bootstrap
8
 * @package modules\rbac
9
 */
10
class Bootstrap
11
{
12
    public function __construct()
13
    {
14
        // i18n
15
        Yii::$app->i18n->translations['modules/rbac/*'] = [
16
            'class' => 'yii\i18n\PhpMessageSource',
17
            'basePath' => '@modules/rbac/messages',
18
            'fileMap' => [
19
                'modules/rbac/module' => 'module.php',
20
            ],
21
        ];
22
23
        // Rules
24
        Yii::$app->getUrlManager()->addRules(
25
            [
26
                // Roles
27
                [
28
                    'class' => 'yii\web\GroupUrlRule',
29
                    'routePrefix' => 'rbac/roles',
30
                    'prefix' => 'rbac',
31
                    'rules' => [
32
                        'roles' => 'index',
33
                        'role/<id:[\w\-]+>/<_a:[\w\-]+>' => '<_a>',
34
                        'role/<_a:[\w\-]+>' => '<_a>',
35
                    ],
36
                ],
37
                // Permissions
38
                [
39
                    'class' => 'yii\web\GroupUrlRule',
40
                    'routePrefix' => 'rbac/permissions',
41
                    'prefix' => 'rbac',
42
                    'rules' => [
43
                        'permissions' => 'index',
44
                        'permission/<id:[\w\-]+>/<_a:[\w\-]+>' => '<_a>',
45
                        'permission/<_a:[\w\-]+>' => '<_a>',
46
                    ],
47
                ],
48
                // Assign
49
                [
50
                    'class' => 'yii\web\GroupUrlRule',
51
                    'routePrefix' => 'rbac/assign',
52
                    'prefix' => 'rbac/assign',
53
                    'rules' => [
54
                        '' => 'index',
55
                        '<id:\d+>/<_a:[\w\-]+>' => '<_a>',
56
                    ],
57
                ],
58
                // Default
59
                [
60
                    'class' => 'yii\web\GroupUrlRule',
61
                    'routePrefix' => 'rbac/default',
62
                    'prefix' => 'rbac',
63
                    'rules' => [
64
                        '' => 'index',
65
                        '<_a:[\w\-]+>' => '<_a>',
66
                    ],
67
                ],
68
            ]
69
        );
70
    }
71
}
72