Test Failed
Push — master ( f235c1...2c36df )
by Nuno
01:49
created

FacadeMethodExtension   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 45
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A subject() 0 3 1
A searchIn() 0 27 5
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\Support\Facades;
15
16
use function get_class;
17
use InvalidArgumentException;
18
use Illuminate\Support\Manager;
19
use Illuminate\Support\Facades\Facade;
20
use PHPStan\Reflection\ClassReflection;
21
use NunoMaduro\LaravelCodeAnalyse\AbstractExtension;
22
use NunoMaduro\LaravelCodeAnalyse\FacadeConcreteClassResolver;
0 ignored issues
show
Bug introduced by
The type NunoMaduro\LaravelCodeAn...deConcreteClassResolver 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...
23
24
final class FacadeMethodExtension extends AbstractExtension
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    protected $staticAccess = true;
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function subject(): string
35
    {
36
        return Facade::class;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    protected function searchIn(ClassReflection $classReflection): array
43
    {
44
        $facadeClass = $classReflection->getName();
45
46
        if ($concrete = $facadeClass::getFacadeRoot()) {
47
48
            $classes = [get_class($concrete)];
49
50
            if ($concrete instanceof Manager) {
51
52
                $driver = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $driver is dead and can be removed.
Loading history...
53
54
                try {
55
                    $driver = $concrete->driver();
56
                } catch (InvalidArgumentException $exception) {
57
                    // ..
58
                }
59
60
                if ($driver !== null) {
61
                    $classes[] = get_class($driver);
62
                }
63
            }
64
65
            return $classes;
66
        }
67
68
        return [NullConcreteClass::class];
69
    }
70
}
71