| Total Complexity | 20 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Coverage | 97.5% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class UserPolicy |
||
| 10 | { |
||
| 11 | use HandlesAuthorization; |
||
| 12 | |||
| 13 | 18 | public function viewAny(User $user): bool |
|
| 20 | } |
||
| 21 | |||
| 22 | 19 | public function view(User $user, User $userModel): bool |
|
| 23 | { |
||
| 24 | 19 | if ($user->hasPermissionTo('user:view:any')) { |
|
| 25 | 10 | return true; |
|
| 26 | } |
||
| 27 | |||
| 28 | 9 | if (! $user->hasPermissionTo('user:view')) { |
|
| 29 | 1 | return false; |
|
| 30 | } |
||
| 31 | |||
| 32 | 8 | if ($user->id === $userModel->id) { |
|
| 33 | 6 | return true; |
|
| 34 | } |
||
| 35 | |||
| 36 | 2 | return false; |
|
| 37 | } |
||
| 38 | |||
| 39 | 13 | public function create(User $user): bool |
|
| 46 | } |
||
| 47 | |||
| 48 | 15 | public function update(User $user, User $userModel): bool |
|
| 49 | { |
||
| 50 | 15 | if ($user->id === $userModel->id) { |
|
| 51 | 8 | return false; |
|
| 52 | } |
||
| 53 | |||
| 54 | 9 | if ($user->hasPermissionTo('user:update:any')) { |
|
| 55 | 6 | return true; |
|
| 56 | } |
||
| 57 | |||
| 58 | 3 | return false; |
|
| 59 | } |
||
| 60 | |||
| 61 | 13 | public function updateOwn(User $user, User $userModel): bool |
|
| 62 | { |
||
| 63 | 13 | if (! $user->hasPermissionTo('user:update')) { |
|
| 64 | 1 | return false; |
|
| 65 | } |
||
| 66 | |||
| 67 | 12 | if ($user->id === $userModel->id) { |
|
| 68 | 8 | return true; |
|
| 69 | } |
||
| 70 | |||
| 71 | 6 | return false; |
|
| 72 | } |
||
| 73 | |||
| 74 | 12 | public function changeEmail(User $user): bool |
|
| 85 | } |
||
| 86 | |||
| 87 | 15 | public function delete(User $user, User $userModel): bool |
|
| 98 | } |
||
| 99 | } |
||
| 100 |