Passed
Push — dev5a ( c41270...352680 )
by Ron
07:09
created

GetRoles::getRoleList()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

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 9
cts 9
cp 1
crap 4
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 6
    public function getRoleList($limit = true)
14
    {
15 6
        $roles = (UserRoleType::all());
16
17 6
        if($limit)
18
        {
19 6
            if(Auth::user()->role_id !== 1)
20
            {
21 2
                $roles->forget(0);
22
            }
23
24 6
            if(Auth::user()->role_id > 2)
25
            {
26 2
                $roles->forget(1);
27
            }
28
        }
29
30 6
        Log::debug('Role list gathered.  Data - ', $roles->toArray());
31 6
        return $roles;
32
    }
33
}
34