Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Lines | 15 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
23 | public function run(DataTransporter $data): Role |
||
24 | { |
||
25 | $role = Apiato::call('[email protected]', [$data->role_id]); |
||
26 | |||
27 | // convert to array in case single ID was passed |
||
28 | $permissionIds = (array)$data->permissions_ids; |
||
29 | |||
30 | $permissions = array_map(function ($permissionId) { |
||
31 | return Apiato::call('[email protected]', [$permissionId]); |
||
32 | }, $permissionIds); |
||
33 | |||
34 | $role = $role->givePermissionTo($permissions); |
||
35 | |||
36 | return $role; |
||
37 | } |
||
38 | } |
||
39 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.