| @@ 75-84 (lines=10) @@ | ||
| 72 | * |
|
| 73 | * @return $this |
|
| 74 | */ |
|
| 75 | public function addRole(string $role): PermissionManager |
|
| 76 | { |
|
| 77 | if ($this->hasRole($role)) { |
|
| 78 | throw new RoleException("Role '{$role}' already exists."); |
|
| 79 | } |
|
| 80 | ||
| 81 | $this->associations[$role] = []; |
|
| 82 | ||
| 83 | return $this; |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * {@inheritdoc} |
|
| @@ 91-100 (lines=10) @@ | ||
| 88 | * |
|
| 89 | * @return $this |
|
| 90 | */ |
|
| 91 | public function removeRole(string $role): PermissionManager |
|
| 92 | { |
|
| 93 | if (!$this->hasRole($role)) { |
|
| 94 | throw new RoleException("Undefined role '{$role}'."); |
|
| 95 | } |
|
| 96 | ||
| 97 | unset($this->associations[$role]); |
|
| 98 | ||
| 99 | return $this; |
|
| 100 | } |
|
| 101 | ||
| 102 | /** |
|
| 103 | * {@inheritdoc} |
|