| Total Complexity | 9 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 12 | trait AutorizableTrait |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var array<string, RoleInterface> |
||
| 16 | */ |
||
| 17 | protected $roles = []; |
||
| 18 | |||
| 19 | 4 | public function can(string $slug): bool |
|
| 20 | { |
||
| 21 | 4 | return $this->isAllowed($slug); |
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | public function canAny(array $slugs): bool |
|
| 33 | } |
||
| 34 | |||
| 35 | 1 | public function canAll(array $slugs): bool |
|
| 44 | } |
||
| 45 | |||
| 46 | 5 | public function attach(RoleInterface $role): void |
|
| 47 | { |
||
| 48 | 5 | $this->roles[$role->name()] = $role; |
|
| 49 | 5 | } |
|
| 50 | |||
| 51 | 5 | public function detach(RoleInterface $role): void |
|
| 54 | 5 | } |
|
| 55 | |||
| 56 | abstract protected function isAllowed(string $slug): bool; |
||
| 57 | } |
||
| 58 |