We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 6 |
| Paths | 8 |
| Total Lines | 56 |
| Lines | 15 |
| Ratio | 26.79 % |
| 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 setup() |
||
| 17 | { |
||
| 18 | $role_model = config('backpack.permissionmanager.models.role'); |
||
|
|
|||
| 19 | $permission_model = config('backpack.permissionmanager.models.permission'); |
||
| 20 | |||
| 21 | $this->crud->setModel($permission_model); |
||
| 22 | $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.permission_singular'), trans('backpack::permissionmanager.permission_plural')); |
||
| 23 | $this->crud->setRoute(backpack_url('permission')); |
||
| 24 | |||
| 25 | // deny access according to configuration file |
||
| 26 | if (config('backpack.permissionmanager.allow_permission_create') == false) { |
||
| 27 | $this->crud->denyAccess('create'); |
||
| 28 | } |
||
| 29 | if (config('backpack.permissionmanager.allow_permission_update') == false) { |
||
| 30 | $this->crud->denyAccess('update'); |
||
| 31 | } |
||
| 32 | if (config('backpack.permissionmanager.allow_permission_delete') == false) { |
||
| 33 | $this->crud->denyAccess('delete'); |
||
| 34 | } |
||
| 35 | |||
| 36 | $this->crud->operation('list', function () { |
||
| 37 | $this->crud->addColumn([ |
||
| 38 | 'name' => 'name', |
||
| 39 | 'label' => trans('backpack::permissionmanager.name'), |
||
| 40 | 'type' => 'text', |
||
| 41 | ]); |
||
| 42 | |||
| 43 | View Code Duplication | if (config('backpack.permissionmanager.multiple_guards')) { |
|
| 44 | $this->crud->addColumn([ |
||
| 45 | 'name' => 'guard_name', |
||
| 46 | 'label' => trans('backpack::permissionmanager.guard_type'), |
||
| 47 | 'type' => 'text', |
||
| 48 | ]); |
||
| 49 | } |
||
| 50 | }); |
||
| 51 | |||
| 52 | $this->crud->operation(['create', 'update'], function () { |
||
| 53 | $this->crud->addField([ |
||
| 54 | 'name' => 'name', |
||
| 55 | 'label' => trans('backpack::permissionmanager.name'), |
||
| 56 | 'type' => 'text', |
||
| 57 | ]); |
||
| 58 | |||
| 59 | View Code Duplication | if (config('backpack.permissionmanager.multiple_guards')) { |
|
| 60 | $this->crud->addField([ |
||
| 61 | 'name' => 'guard_name', |
||
| 62 | 'label' => trans('backpack::permissionmanager.guard_type'), |
||
| 63 | 'type' => 'select_from_array', |
||
| 64 | 'options' => $this->getGuardTypes(), |
||
| 65 | ]); |
||
| 66 | } |
||
| 67 | |||
| 68 | //otherwise, changes won't have effect |
||
| 69 | \Cache::forget('spatie.permission.cache'); |
||
| 70 | }); |
||
| 71 | } |
||
| 72 | |||
| 91 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.