Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | public static function isPermittedEnvironment(ContainerBuilder $container, \ReflectionClass $reflectionClass): bool |
||
30 | { |
||
31 | $currentEnvironment = $container->getParameter('kernel.environment'); |
||
32 | $permittedEnvironments = ArrayList::collect($reflectionClass->getAttributes(When::class)) |
||
33 | ->map(static fn (\ReflectionAttribute $attribute) => $attribute->newInstance()->env) |
||
34 | ; |
||
35 | |||
36 | $isEnvironmentIsNotDefined = $permittedEnvironments->isEmpty(); |
||
37 | $isEnvironmentPermitted = $permittedEnvironments |
||
38 | ->first(static fn (string $environment) => $environment === $currentEnvironment) |
||
39 | ->isSome() |
||
40 | ; |
||
41 | |||
42 | return $isEnvironmentPermitted || $isEnvironmentIsNotDefined; |
||
43 | } |
||
45 |