| Total Complexity | 5 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | trait PermissionTrait |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var array User permissions |
||
| 21 | */ |
||
| 22 | protected $permission = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Check if a Permission is owned, use Permission instance. |
||
| 26 | * |
||
| 27 | * @param Permission $permission |
||
| 28 | * |
||
| 29 | * @return bool |
||
| 30 | */ |
||
| 31 | public function can(Permission $permission): bool |
||
| 32 | { |
||
| 33 | 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 | 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 | public function canByName(string $permissionName): bool |
||
| 66 | } |
||
| 67 | } |
||
| 68 |