Total Complexity | 4 |
Total Lines | 64 |
Duplicated Lines | 0 % |
Coverage | 18.75% |
Changes | 2 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
8 | trait RolesManager |
||
9 | { |
||
10 | private $roles = []; |
||
11 | |||
12 | abstract public function getRoles(); |
||
13 | |||
14 | /** |
||
15 | * @param RoleInterface $role |
||
16 | * |
||
17 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
||
18 | * |
||
19 | * @return self |
||
20 | */ |
||
21 | public function assignRole(RoleInterface $role): self |
||
22 | { |
||
23 | $this->roles = app()->make(RoleModel::class) |
||
24 | ->assignRole($this->getRoles(), $role); |
||
25 | |||
26 | return $this; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param array $roles |
||
31 | * |
||
32 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
||
33 | * |
||
34 | * @return self |
||
35 | */ |
||
36 | 1 | public function assignRoles(array $roles): self |
|
37 | { |
||
38 | 1 | $this->roles = app()->make(RoleModel::class) |
|
39 | 1 | ->assignRoles($this->getRoles(), $roles); |
|
40 | |||
41 | return $this; |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param RoleInterface $role |
||
46 | * |
||
47 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
||
48 | * |
||
49 | * @return self |
||
50 | */ |
||
51 | public function removeRole(RoleInterface $role): self |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @param array $roles |
||
61 | * |
||
62 | * @throws \Illuminate\Contracts\Container\BindingResolutionException |
||
63 | * |
||
64 | * @return self |
||
65 | */ |
||
66 | public function removeRoles(array $roles): self |
||
72 | } |
||
73 | } |
||
74 |