| Total Complexity | 5 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare( strict_types=1 ); |
||
| 13 | class ParentTest extends TestCase |
||
| 14 | { |
||
| 15 | protected function getEnvironmentVariable ( string $variableName, $default, $castingFunctionName = null ) |
||
| 16 | { |
||
| 17 | $keyExists = array_key_exists( $variableName, $_ENV ); |
||
| 18 | $value = null; |
||
| 19 | |||
| 20 | if ( $keyExists ) { |
||
| 21 | $value = $_ENV[$variableName]; |
||
| 22 | } else { |
||
| 23 | $dotenv = Dotenv::createImmutable( __DIR__ . "/../../" ); |
||
| 24 | $dotenv->load(); |
||
| 25 | |||
| 26 | $value = getenv( $variableName ); |
||
| 27 | |||
| 28 | if ( empty( $value ) ) { |
||
| 29 | $value = $default; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | if ( !empty( $castingFunctionName ) ) { |
||
| 34 | return call_user_func( $castingFunctionName, $value ); |
||
| 35 | } |
||
| 36 | |||
| 37 | return $value; |
||
| 38 | } |
||
| 39 | |||
| 40 | public function testCanGetDefaultValueForEnvVar () : void |
||
| 48 | } |
||
| 49 | } |
||
| 50 |