GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( ab0f17...5c551e )
by Mehdi
11:24
created

QueryFilterCoreBuilder::setDetectFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace eloquentFilter\QueryFilter\Core\FilterBuilder\core;
4
5
use eloquentFilter\QueryFilter\Detection\DetectionFactory;
6
7
/**
8
 * Class QueryFilterCoreBuilder.
9
 */
10
class QueryFilterCoreBuilder implements QueryFilterCore
11
{
12
    /**
13
     * @var
14
     */
15
    protected $builder;
16
17
    /**
18
     * @var array
19
     */
20
    protected array $detections;
21
22
    /**
23
     * @var
24
     */
25
    protected $injected_detections;
26
27
    /**
28
     * @var array
29
     */
30
    protected array $default_detect;
31
32
    /**
33
     * @var DetectionFactory
34
     */
35
    private DetectionFactory $detect_factory;
36
37
    /**
38
     * QueryFilter constructor.
39
     *
40
     * @param array $default_injected
41
     * @param array|null $detect_injected
42
     */
43
    public function __construct(array $default_injected, array $detect_injected = null)
44
    {
45
        if (!empty($detect_injected)) {
46
            $this->setInjectedDetections($detect_injected);
47
        }
48
49
        $this->setDefaultDetect($default_injected);
50
        $this->setDetectFactory($this->getDetectorFactory($this->getDefaultDetect(), $this->getInjectedDetections()));
51
    }
52
53
    /**
54
     * @param mixed $default_detect
55
     */
56
    public function setDefaultDetect($default_detect): void
57
    {
58
        $this->default_detect = $default_detect;
59
    }
60
61
    /**
62
     * @return array
63
     */
64
    public function getDefaultDetect(): array
65
    {
66
        return $this->default_detect;
67
    }
68
69
    /**
70
     * @param array $detections
71
     */
72
    public function setDetections(array $detections): void
73
    {
74
        $this->detections = $detections;
75
    }
76
77
    /**
78
     * @param DetectionFactory $detect_factory
79
     */
80
    public function setDetectFactory(DetectionFactory $detect_factory): void
81
    {
82
        $this->detect_factory = $detect_factory;
83
    }
84
85
    /**
86
     * @return DetectionFactory
87
     */
88
    public function getDetectFactory(): DetectionFactory
89
    {
90
        return $this->detect_factory;
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    public function getDetections(): array
97
    {
98
        return $this->detections;
99
    }
100
101
    /**
102
     * @param mixed $detect_injected
103
     */
104
    public function setInjectedDetections($detect_injected): void
105
    {
106
        if (!config('eloquentFilter.enabled_custom_detection')) {
107
            return;
108
        }
109
        $this->injected_detections = $detect_injected;
110
    }
111
112
    /**
113
     * @return mixed
114
     */
115
    public function getInjectedDetections()
116
    {
117
        return $this->injected_detections;
118
    }
119
120
    /**
121
     * @param array|null $default_detect
122
     * @param array|null $detect_injected
123
     *
124
     * @return DetectionFactory
125
     */
126
    public function getDetectorFactory(array $default_detect = null, array $detect_injected = null): DetectionFactory
127
    {
128
        $detections = $default_detect;
129
130
        if (!empty($detect_injected)) {
131
            $detections = array_merge($detect_injected, $default_detect);
0 ignored issues
show
Bug introduced by
It seems like $default_detect can also be of type null; however, parameter $arrays of array_merge() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

131
            $detections = array_merge($detect_injected, /** @scrutinizer ignore-type */ $default_detect);
Loading history...
132
        }
133
134
        $this->setDetections($detections);
0 ignored issues
show
Bug introduced by
It seems like $detections can also be of type null; however, parameter $detections of eloquentFilter\QueryFilt...uilder::setDetections() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

134
        $this->setDetections(/** @scrutinizer ignore-type */ $detections);
Loading history...
135
136
        return app(DetectionFactory::class, ['detections' => $this->getDetections()]);
137
    }
138
}
139