Passed
Branch dev5a (c41270)
by Ron
12:51
created

GetRoles::getRoleList()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.1755

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 8
c 1
b 0
f 0
nc 5
nop 1
dl 0
loc 19
ccs 7
cts 9
cp 0.7778
crap 4.1755
rs 10
1
<?php
2
3
namespace App\Domains\Roles;
4
5
use App\UserRoleType;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
9
10
class GetRoles
11
{
12
    //  Gather a list of roles available  if the limit is turned on, installer and admin roles will not be returned for lower level users
13 2
    public function getRoleList($limit = true)
14
    {
15 2
        $roles = (UserRoleType::all());
16
17 2
        if($limit)
18
        {
19 2
            if(Auth::user()->role_id !== 1)
20
            {
21
                $roles->forget(0);
22
            }
23
24 2
            if(Auth::user()->role_id > 2)
25
            {
26
                $roles->forget(1);
27
            }
28
        }
29
30 2
        Log::debug('Role list gathered.  Data - ', $roles->toArray());
31 2
        return $roles;
32
    }
33
}
34