| Conditions | 3 |
| Paths | 3 |
| Total Lines | 51 |
| Code Lines | 30 |
| 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 |
||
| 14 | public function run() |
||
| 15 | { |
||
| 16 | /* |
||
| 17 | * Permission Types |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | $Permissionitems = [ |
||
| 21 | [ |
||
| 22 | 'name' => 'Can View Users', |
||
| 23 | 'slug' => 'view.users', |
||
| 24 | 'description' => 'Can view users', |
||
| 25 | 'model' => 'Permission', |
||
| 26 | ], |
||
| 27 | [ |
||
| 28 | 'name' => 'Can Create Users', |
||
| 29 | 'slug' => 'create.users', |
||
| 30 | 'description' => 'Can create new users', |
||
| 31 | 'model' => 'Permission', |
||
| 32 | ], |
||
| 33 | [ |
||
| 34 | 'name' => 'Can Edit Users', |
||
| 35 | 'slug' => 'edit.users', |
||
| 36 | 'description' => 'Can edit users', |
||
| 37 | 'model' => 'Permission', |
||
| 38 | ], |
||
| 39 | [ |
||
| 40 | 'name' => 'Can Delete Users', |
||
| 41 | 'slug' => 'delete.users', |
||
| 42 | 'description' => 'Can delete users', |
||
| 43 | 'model' => 'Permission', |
||
| 44 | ], |
||
| 45 | ]; |
||
| 46 | |||
| 47 | /* |
||
| 48 | * Add Permission Items |
||
| 49 | * |
||
| 50 | */ |
||
| 51 | $this->command->getOutput()->writeln('<info>Seeding:</info> DefaultPermissionitemsTableSeeder'); |
||
| 52 | foreach ($Permissionitems as $Permissionitem) { |
||
| 53 | $newPermissionitem = config('roles.models.permission')::where('slug', '=', $Permissionitem['slug']) |
||
| 54 | ->first(); |
||
| 55 | if ($newPermissionitem === null) { |
||
| 56 | $newPermissionitem = config('roles.models.permission')::create([ |
||
|
|
|||
| 57 | 'name' => $Permissionitem['name'], |
||
| 58 | 'slug' => $Permissionitem['slug'], |
||
| 59 | 'description' => $Permissionitem['description'], |
||
| 60 | 'model' => $Permissionitem['model'], |
||
| 61 | ]); |
||
| 62 | $this->command->getOutput()->writeln( |
||
| 63 | '<info>Seeding:</info> DefaultPermissionitemsTableSeeder - Permission:' |
||
| 64 | .$Permissionitem['slug'] |
||
| 65 | ); |
||
| 70 |