| Conditions | 10 |
| Paths | 15 |
| Total Lines | 30 |
| Code Lines | 18 |
| 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 |
||
| 63 | private function updateRolePermissions($role, $fields) |
||
| 64 | { |
||
| 65 | foreach (Permission::available(Permission::SCOPE_GLOBAL) as $permissionName) { |
||
| 66 | if (isset($fields[$permissionName]) && $fields[$permissionName] === true) { |
||
| 67 | $role->grantGlobalPermission($permissionName); |
||
| 68 | } else { |
||
| 69 | $role->revokeGlobalPermission($permissionName); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | foreach ($fields as $key => $permissionName) { |
||
| 74 | if (Str::startsWith($key, 'module_') && Str::endsWith($key, '_permissions')) { |
||
| 75 | $modulePermissions = Permission::available(Permission::SCOPE_MODULE); |
||
| 76 | $model = getModelByModuleName($moduleName = explode('_', $key)[1]); |
||
| 77 | |||
| 78 | $currentPermission = $role->permissions() |
||
| 79 | ->where('permissionable_type', $model) |
||
| 80 | ->whereIn('name', $modulePermissions) |
||
| 81 | ->first(); |
||
| 82 | |||
| 83 | if (!$currentPermission || $permissionName != $currentPermission->name) { |
||
| 84 | $role->revokeAllModulePermission($model); |
||
| 85 | if (in_array($permissionName, $modulePermissions)) { |
||
| 86 | $role->grantModulePermission($permissionName, $model); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | $role->save(); |
||
| 93 | } |
||
| 95 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths