| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | public function givePermissionTo(...$permissions) |
||
| 17 | { |
||
| 18 | collect($permissions) |
||
| 19 | ->flatten() |
||
| 20 | ->map(function ($permission) { |
||
| 21 | return $this->getStoredPermission($permission); |
||
| 22 | }) |
||
| 23 | ->each(function (Permission $permission) { |
||
| 24 | return $this->permissions()->save($permission); |
||
| 25 | }); |
||
| 26 | |||
| 27 | $this->forgetCachedPermissions(); |
||
| 28 | |||
| 29 | return $this; |
||
| 30 | } |
||
| 31 | |||
| 66 |
In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.
If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.