Conditions | 3 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | public function configure(ConfigurableObjectInterface $config) |
||
|
|||
9 | { |
||
10 | $variablePrefix = 'MAGIUM_' . str_replace('\\', '_', strtoupper(get_class($config))) . '_'; |
||
11 | |||
12 | foreach ($_ENV as $key => $value) { |
||
13 | if (strpos($key, $variablePrefix) === 0) { |
||
14 | $property = substr($key, strlen($variablePrefix)); |
||
15 | $config->set($property, $value); |
||
16 | } |
||
17 | } |
||
18 | } |
||
19 | |||
20 | } |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: