Completed
Pull Request — master (#420)
by
unknown
07:32 queued 42s
created

UserResolver::resolve()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 7
cp 0.8571
rs 9.2
c 0
b 0
f 0
cc 4
eloc 6
nc 5
nop 0
crap 4.0466
1
<?php
2
/**
3
 * This file is part of the Laravel Auditing package.
4
 *
5
 * @author     Antério Vieira <[email protected]>
6
 * @author     Quetzy Garcia  <[email protected]>
7
 * @author     Raphael França <[email protected]>
8
 * @copyright  2015-2018
9
 *
10
 * For the full copyright and license information,
11
 * please view the LICENSE.md file that was distributed
12
 * with this source code.
13
 */
14
15
namespace OwenIt\Auditing\Resolvers;
16
17
use Illuminate\Support\Facades\Auth;
18
use Illuminate\Support\Facades\Config;
19
20
class UserResolver implements \OwenIt\Auditing\Contracts\UserResolver
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 216
    public static function resolve()
26
    {
27 216
        $guards = Config::get('audit.guards', ['web']);
28
29 216
        foreach ($guards as $guard) {
30 216
            if (Auth::guard($guard)->check()) {
31 216
                return Auth::guard($guard)->user();
32
            }
33
        }
34
35 216
        if (Auth::check()) {
36
            return Auth::user();
37
        }
38 216
    }
39
}
40