| Total Complexity | 9 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | abstract class Role |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Whether the current user can update from oldRole to newRole. |
||
| 13 | * |
||
| 14 | * The current user is allowed to promote another user up to the same role as himself. So |
||
| 15 | * a Senior can promote a Student to Senior. Or an Admin can promote a Junior to Admin. |
||
| 16 | * |
||
| 17 | * But the current user is **not** allowed to demote a user who has a higher role than himself. |
||
| 18 | * That means that a Senior cannot demote an Admin to Student. |
||
| 19 | */ |
||
| 20 | 17 | public static function canUpdate(?User $currentUser, string $oldRole, string $newRole): bool |
|
| 58 |