| 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 | '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 | } |
||
| 72 |