SessionGuardHelper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 10
cp 0
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fetchModel() 0 7 2
A guardedModel() 0 5 2
A authModel() 0 3 1
1
<?php
2
3
namespace Terranet\Administrator\Traits;
4
5
trait SessionGuardHelper
6
{
7
    /**
8
     * Fetch auth model from Laravel 5.2 auth config.
9
     */
10
    protected function guardedModel()
11
    {
12
        return ($provider = config('auth.guards.admin.provider'))
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

12
        return ($provider = /** @scrutinizer ignore-call */ config('auth.guards.admin.provider'))
Loading history...
13
            ? config('auth.providers')[$provider]['model']
14
            : null;
15
    }
16
17
    /**
18
     * Fetch auth model from Administrator config or Laravel 5.1 auth config.
19
     *
20
     * @param $config
21
     *
22
     * @return mixed
23
     */
24
    protected function authModel($config)
25
    {
26
        return $config->get('auth.model', config('auth.model'));
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

26
        return $config->get('auth.model', /** @scrutinizer ignore-call */ config('auth.model'));
Loading history...
27
    }
28
29
    /**
30
     * Fetch authentication model.
31
     *
32
     * @param $config
33
     *
34
     * @return null|mixed
35
     */
36
    protected function fetchModel($config)
37
    {
38
        if (guarded_auth()) {
39
            return $this->guardedModel();
40
        }
41
42
        return $this->authModel($config);
43
    }
44
}
45