Total Complexity | 5 |
Total Lines | 49 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
17 | trait PermissionTrait |
||
18 | { |
||
19 | /** |
||
20 | * @var array<mixed> User permissions |
||
21 | */ |
||
22 | protected array $permission = []; |
||
23 | |||
24 | /** |
||
25 | * Check if a Permission is owned, use Permission instance. |
||
26 | * |
||
27 | * @param Permission $permission |
||
28 | * |
||
29 | * @return bool |
||
30 | */ |
||
31 | 32 | public function can(Permission $permission): bool |
|
32 | { |
||
33 | 32 | return $this->canById($permission->getId()); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * Check if a Permission is owned, use permission Id. |
||
38 | * |
||
39 | * @param int $permissionId |
||
40 | * |
||
41 | * @return bool |
||
42 | */ |
||
43 | 62 | public function canById(int $permissionId): bool |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * Check if a Permission is owned, use permission name. |
||
54 | * |
||
55 | * @param string $permissionName |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 32 | public function canByName(string $permissionName): bool |
|
66 | } |
||
67 | } |
||
68 |