AuthenticatableExtension::searchIn()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Laravel Code Analyse.
7
 *
8
 * (c) Nuno Maduro <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace NunoMaduro\LaravelCodeAnalyse\Contracts\Auth;
15
16
use Illuminate\Container\Container;
17
use PHPStan\Reflection\ClassReflection;
18
use Illuminate\Contracts\Auth\Authenticatable;
19
use NunoMaduro\LaravelCodeAnalyse\AbstractExtension;
20
use Illuminate\Contracts\Container\Container as ContainerContract;
21
22
/**
23
 * @internal
24
 */
25
final class AuthenticatableExtension extends AbstractExtension
26
{
27
    /**
28
     * @var \Illuminate\Contracts\Container\Container
29
     */
30
    private $container;
31
32
    /**
33
     * AuthenticatableExtension constructor.
34
     *
35
     * @param \Illuminate\Contracts\Container\Container|null $container
36
     */
37
    public function __construct(ContainerContract $container = null)
38
    {
39
        $this->container = $container;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    protected function subject(): string
46
    {
47
        return Authenticatable::class;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    protected function searchIn(ClassReflection $classReflection): array
54
    {
55
        $config = ($this->container ?? Container::getInstance())->get('config');
56
57
        $userModel = $config->get('auth.providers.users.model');
58
59
        return [$userModel];
60
    }
61
}
62