Completed
Pull Request — master (#420)
by
unknown
05:39
created

UserClassResolver::resolveUser()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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 OwenIt\Auditing\Exceptions\AuditingException;
18
19
class UserClassResolver implements \OwenIt\Auditing\Contracts\UserClassResolver
0 ignored issues
show
Bug introduced by
The type OwenIt\Auditing\Contracts\UserClassResolver was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public static function resolve()
25
    {
26
        return static::resolveUser() ? static::resolveUser()->getMorphClass() : null;
27
    }
28
29
    /**
30
     * Resolves the user.
31
     *
32
     * @throws AuditingException
33
     *
34
     * @return mixed
35
     */
36
    protected static function resolveUser()
37
    {
38
        $userResolver = \Config::get('audit.resolver.user');
39
40
        if (is_subclass_of($userResolver, \OwenIt\Auditing\Contracts\UserResolver::class)) {
41
            return call_user_func([$userResolver, 'resolve']);
42
        }
43
44
        throw new AuditingException('Invalid UserResolver implementation');
45
    }
46
}
47