| Conditions | 2 |
| Paths | 2 |
| Total Lines | 70 |
| Code Lines | 40 |
| 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 |
||
| 17 | function roles_get_roles_config($hook_name, $entity_type, $return_value, $params) {
|
||
| 18 | |||
| 19 | $roles = array( |
||
| 20 | |||
| 21 | VISITOR_ROLE => array( |
||
| 22 | 'title' => 'roles:role:VISITOR_ROLE', |
||
| 23 | 'extends' => array(), |
||
| 24 | 'permissions' => array( |
||
| 25 | 'actions' => array( |
||
| 26 | ), |
||
| 27 | 'menus' => array( |
||
| 28 | ), |
||
| 29 | 'views' => array( |
||
| 30 | ), |
||
| 31 | 'hooks' => array( |
||
| 32 | ), |
||
| 33 | ), |
||
| 34 | ), |
||
| 35 | |||
| 36 | DEFAULT_ROLE => array( |
||
| 37 | 'title' => 'roles:role:DEFAULT_ROLE', |
||
| 38 | 'extends' => array(), |
||
| 39 | 'permissions' => array( |
||
| 40 | 'actions' => array( |
||
| 41 | ), |
||
| 42 | 'menus' => array( |
||
| 43 | ), |
||
| 44 | 'views' => array( |
||
| 45 | ), |
||
| 46 | 'hooks' => array( |
||
| 47 | ), |
||
| 48 | ), |
||
| 49 | ), |
||
| 50 | |||
| 51 | ADMIN_ROLE => array( |
||
| 52 | 'title' => 'roles:role:ADMIN_ROLE', |
||
| 53 | 'extends' => array(), |
||
| 54 | 'permissions' => array( |
||
| 55 | 'actions' => array( |
||
| 56 | ), |
||
| 57 | 'menus' => array( |
||
| 58 | ), |
||
| 59 | 'views' => array( |
||
| 60 | 'forms/account/settings' => array( |
||
| 61 | 'rule' => 'extend', |
||
| 62 | 'view_extension' => array( |
||
| 63 | 'view' => 'roles/settings/account/role', |
||
| 64 | 'priority' => 150 |
||
| 65 | ) |
||
| 66 | ), |
||
| 67 | ), |
||
| 68 | 'hooks' => array( |
||
| 69 | 'usersettings:save::user' => array( |
||
| 70 | 'rule' => 'extend', |
||
| 71 | 'hook' => array( |
||
| 72 | 'handler' => 'roles_user_settings_save', |
||
| 73 | 'priority' => 500, |
||
| 74 | ) |
||
| 75 | ), |
||
| 76 | ), |
||
| 77 | ), |
||
| 78 | ), |
||
| 79 | ); |
||
| 80 | |||
| 81 | if (!is_array($return_value)) {
|
||
| 82 | return $roles; |
||
| 83 | } else {
|
||
| 84 | return array_merge($return_value, $roles); |
||
| 85 | } |
||
| 86 | } |
||
| 87 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.