Conditions | 9 |
Paths | 9 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 9 |
Changes | 0 |
1 | <?php |
||
18 | 532 | public function canInitialize(BootloaderInterface|string $bootloader, ?BootloadConfig $config = null): bool |
|
19 | { |
||
20 | 532 | if ($config === null) { |
|
21 | 423 | return true; |
|
22 | } |
||
23 | |||
24 | 529 | if (!$config->enabled) { |
|
25 | 4 | return false; |
|
26 | } |
||
27 | |||
28 | 528 | foreach ($config->denyEnv as $env => $denyValues) { |
|
29 | 22 | $value = $this->environment->get($env); |
|
30 | 22 | if ($value !== null && \in_array($value, (array) $denyValues, true)) { |
|
31 | 17 | return false; |
|
32 | } |
||
33 | } |
||
34 | |||
35 | 511 | foreach ($config->allowEnv as $env => $allowValues) { |
|
36 | 14 | $value = $this->environment->get($env); |
|
37 | 14 | if ($value === null || !\in_array($value, (array) $allowValues, true)) { |
|
38 | 10 | return false; |
|
39 | } |
||
40 | } |
||
41 | |||
42 | 501 | return true; |
|
43 | } |
||
45 |