RolesUsageAuthTrait::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
namespace jeremykenedy\LaravelRoles\Traits;
4
5
trait RolesUsageAuthTrait
6
{
7
    /**
8
     * Variable to hold if we are using built in Laravel authentication.
9
     */
10
    private $_rolesGuiAuthEnabled;
11
12
    /**
13
     * Variable to hold if we are using roles/permissoins middleware for access.
14
     */
15
    private $_rolesGuiMiddlewareEnabled;
16
17
    /**
18
     * Variable to hold what roles/permissions middleware we are using if enabled.
19
     */
20
    private $_rolesGuiMiddleware;
21
22
    /**
23
     * Create a new controller instance.
24
     *
25
     * @return void
26
     */
27
    public function __construct()
28
    {
29
        $this->_rolesGuiAuthEnabled = config('roles.rolesGuiAuthEnabled');
30
        $this->_rolesGuiMiddlewareEnabled = config('roles.rolesGuiMiddlewareEnabled');
31
        $this->_rolesGuiMiddleware = config('roles.rolesGuiMiddleware');
32
33
        if ($this->_rolesGuiAuthEnabled) {
34
            $this->middleware('auth');
0 ignored issues
show
Bug introduced by
It seems like middleware() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
            $this->/** @scrutinizer ignore-call */ 
35
                   middleware('auth');
Loading history...
35
        }
36
37
        if ($this->_rolesGuiMiddlewareEnabled) {
38
            $this->middleware($this->_rolesGuiMiddleware);
39
        }
40
    }
41
}
42