Completed
Pull Request — master (#108)
by
unknown
03:33
created

Auth::getAuth()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3.0416
1
<?php
2
3
namespace PragmaRX\Google2FALaravel\Support;
4
5
trait Auth
6
{
7
    /**
8
     * The auth instance.
9
     *
10
     * @var
11
     */
12
    protected $auth;
13
14
    /**
15
     * Get or make an auth instance.
16
     *
17
     * @return \Illuminate\Foundation\Application|mixed
18
     */
19 10
    protected function getAuth()
20
    {
21 10
        if (is_null($this->auth)) {
22 10
            $this->auth = app($this->config('auth'));
23 10
            if(!empty($this->config('guard'))){
24
                $this->auth = app($this->config('auth'))->guard($this->config('guard'));
25
            }
26
        }
27
28 10
        return $this->auth;
29
    }
30
31
    /**
32
     * Get the current user.
33
     *
34
     * @return mixed
35
     */
36 10
    protected function getUser()
37
    {
38 10
        return $this->getAuth()->user();
39
    }
40
41
    abstract protected function config($string, $children = []);
42
}
43