SessionGuardHelper::guardedModel()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 6
rs 10
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