| Total Complexity | 3 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class RoleCalculator |
||
| 8 | { |
||
| 9 | public function __construct(private Guide $guide) |
||
| 10 | { |
||
| 11 | } |
||
| 12 | |||
| 13 | public function setRole(int $userId, string $role): void |
||
| 14 | { |
||
| 15 | $currentRole = $this->guide->roles()->forUser($userId)->firstOrNew(); |
||
| 16 | |||
| 17 | $currentRole->role = $role; |
||
| 18 | $currentRole->user_id = $userId; |
||
| 19 | $currentRole->save(); |
||
| 20 | |||
| 21 | $this->guide->role = $this->calculateRole(); |
||
| 22 | } |
||
| 23 | |||
| 24 | private function calculateRole(): string |
||
| 30 | } |
||
| 31 | } |
||
| 32 |