Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
38 changes: 0 additions & 38 deletions src/Parser.php

This file was deleted.

16 changes: 12 additions & 4 deletions src/SecureEnvPHP.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<?php declare(strict_types = 1);
<?php declare(strict_types=1);

namespace SecureEnvPHP;

use Symfony\Component\Dotenv\Dotenv;

class SecureEnvPHP
{
private Dotenv $dotenv;

public function parse(string $path = Constants::ENV_ENC, string $secret = '', string $algo = Constants::ALGO): void
{
if ($decrypted = (new Crypto())->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();
}
}
24 changes: 0 additions & 24 deletions tests/ParserTest.php

This file was deleted.