Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
50.00% |
4 / 8 |
|
62.50% |
5 / 8 |
|
14.29% |
1 / 7 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| CliEnvVarPocessor | |
50.00% |
4 / 8 |
|
62.50% |
5 / 8 |
|
14.29% |
1 / 7 |
|
0.00% |
0 / 2 |
20.74 | |
0.00% |
0 / 1 |
| getEnv | |
80.00% |
4 / 5 |
|
71.43% |
5 / 7 |
|
16.67% |
1 / 6 |
|
0.00% |
0 / 1 |
13.26 | |||
| getProvidedTypes | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App; |
| 4 | |
| 5 | use Closure; |
| 6 | use Exception; |
| 7 | use Symfony\Component\DependencyInjection\EnvVarProcessorInterface; |
| 8 | |
| 9 | class CliEnvVarPocessor implements EnvVarProcessorInterface |
| 10 | { |
| 11 | public function getEnv(string $prefix, string $name, Closure $getEnv): string |
| 12 | { |
| 13 | $env = $getEnv($name); |
| 14 | if (defined('STDIN')) { |
| 15 | try { |
| 16 | $env = $getEnv($name . '_CLI'); |
| 17 | } catch (Exception) { |
| 18 | // Do nothing |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | return is_scalar($env) ? strval($env) : ''; |
| 23 | } |
| 24 | |
| 25 | public static function getProvidedTypes(): array |
| 26 | { |
| 27 | return [ |
| 28 | 'cli' => 'string', |
| 29 | ]; |
| 30 | } |
| 31 | } |