diff --git a/.travis.yml b/.travis.yml index 66231e6..58aefd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php php: - - 7.1 - - 7.2 - - 7.3 + - 7.4 + - 8.4 install: - travis_retry composer install --no-interaction --ignore-platform-reqs before_script: diff --git a/composer.json b/composer.json index dd84364..2b4212c 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,11 @@ } ], "require": { - "php": ">=7.1" + "php": ">=7.4", + "symfony/dotenv": ">=5.4" }, "require-dev": { - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^8.5" }, "autoload": { "psr-4": { diff --git a/src/Parser.php b/src/Parser.php deleted file mode 100644 index a5a8880..0000000 --- a/src/Parser.php +++ /dev/null @@ -1,38 +0,0 @@ - 0 && strpos($value, '"') === 0 && substr($value, -1) === '"') { - $value = preg_replace('/\\n/gm', "\n", $value); - } - - $value = trim(preg_replace('/(^[\'"]|[\'"]$)/', '', $value)); - - $object[$key] = $value; - } - } - - return $object; - } -} diff --git a/src/SecureEnvPHP.php b/src/SecureEnvPHP.php index 719aa26..117427a 100644 --- a/src/SecureEnvPHP.php +++ b/src/SecureEnvPHP.php @@ -1,19 +1,27 @@ -decrypt($path, $secret, $algo)) { - $parsed = Parser::parse($decrypted) ?? []; - + $parsed = $this->dotenvInstance()->parse($decrypted, basename($path)) ?? []; foreach ($parsed as $key => $value) { if (isset($parsed[$key]) && !empty($parsed[$key])) { - putenv($key.'='.$value); + putenv($key . '=' . $value); } } } } + + private function dotenvInstance() + { + return $this->dotenv ??= new Dotenv(); + } } diff --git a/tests/ParserTest.php b/tests/ParserTest.php deleted file mode 100644 index 54ea24b..0000000 --- a/tests/ParserTest.php +++ /dev/null @@ -1,24 +0,0 @@ -decrypt(Constants::ENV_ENC_TEST, Constants::ENV_KEY_TEST); - - $parsed = Parser::parse($decrypt); - - $this->assertNotEmpty($parsed); - $this->assertSame(['FOO' => 'bar'], $parsed); - } -}