Passed
Push — dev6 ( 77ef26...6e2ff7 )
by Ron
16:42
created

GetUserRoles   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 17 3
1
<?php
2
3
namespace App\Actions;
4
5
use App\Models\User;
6
use App\Models\UserRoles;
7
use Illuminate\Support\Facades\Auth;
8
use Illuminate\Support\Facades\Log;
9
10
11
class GetUserRoles
12
{
13
    public function run(User $user)
14
    {
15
        $userRole = $user->role_id;
16
17
        switch($userRole)
18
        {
19
            case 1:
20
                $roles = UserRoles::all();
21
                break;
22
            case 2:
23
                $roles = UserRoles::where('role_id', '>=', 2)->get();
24
                break;
25
            default:
26
                $roles = UserRoles::where('role_id', '>', 2)->get();
27
        }
28
29
        return $roles;
30
    }
31
}
32