Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
16 | public function bootstrap($app) |
||
|
|||
17 | { |
||
18 | // i18n |
||
19 | $app->i18n->translations['modules/rbac/*'] = [ |
||
20 | 'class' => 'yii\i18n\PhpMessageSource', |
||
21 | 'basePath' => '@modules/rbac/messages', |
||
22 | 'fileMap' => [ |
||
23 | 'modules/rbac/module' => 'module.php', |
||
24 | ], |
||
25 | ]; |
||
26 | |||
27 | // Rules |
||
28 | $app->getUrlManager()->addRules( |
||
29 | [ |
||
30 | // Roles |
||
31 | [ |
||
32 | 'class' => 'yii\web\GroupUrlRule', |
||
33 | 'routePrefix' => 'rbac/roles', |
||
34 | 'prefix' => 'rbac', |
||
35 | 'rules' => [ |
||
36 | 'roles' => 'index', |
||
37 | 'role/<id:[\w\-]+>/<_a:[\w\-]+>' => '<_a>', |
||
38 | 'role/<_a:[\w\-]+>' => '<_a>', |
||
39 | ], |
||
40 | ], |
||
41 | // Permissions |
||
42 | [ |
||
43 | 'class' => 'yii\web\GroupUrlRule', |
||
44 | 'routePrefix' => 'rbac/permissions', |
||
45 | 'prefix' => 'rbac', |
||
46 | 'rules' => [ |
||
47 | 'permissions' => 'index', |
||
48 | 'permission/<id:[\w\-]+>/<_a:[\w\-]+>' => '<_a>', |
||
49 | 'permission/<_a:[\w\-]+>' => '<_a>', |
||
50 | ], |
||
51 | ], |
||
52 | // Assign |
||
53 | [ |
||
54 | 'class' => 'yii\web\GroupUrlRule', |
||
55 | 'routePrefix' => 'rbac/assign', |
||
56 | 'prefix' => 'rbac/assign', |
||
57 | 'rules' => [ |
||
58 | '' => 'index', |
||
59 | '<id:\d+>/<_a:[\w\-]+>' => '<_a>', |
||
60 | ], |
||
61 | ], |
||
62 | // Default |
||
63 | [ |
||
64 | 'class' => 'yii\web\GroupUrlRule', |
||
65 | 'routePrefix' => 'rbac/default', |
||
66 | 'prefix' => 'rbac', |
||
67 | 'rules' => [ |
||
68 | '' => 'index', |
||
69 | '<_a:[\w\-]+>' => '<_a>', |
||
70 | ], |
||
76 |