Total Complexity | 3 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | class Dotenv implements Adapter |
||
21 | { |
||
22 | /** |
||
23 | * Path to the .env file |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private $file; |
||
28 | |||
29 | /** |
||
30 | * Actual dot env reader |
||
31 | * |
||
32 | * @var \Dotenv\Dotenv |
||
33 | */ |
||
34 | private $dotenv; |
||
35 | |||
36 | /** |
||
37 | * Setup the adapter. |
||
38 | * |
||
39 | * @param array $conf |
||
40 | * @return void |
||
41 | */ |
||
42 | 2 | public function setup(array $conf) |
|
43 | { |
||
44 | 2 | $path = AppUtil\Arr::getValue($conf, 'file', '.env'); |
|
45 | 2 | $this->file = AppUtil\Path::toAbsolutePath($path, Configuration::getWorkingDirectory()); |
|
46 | 2 | ||
47 | 2 | // dotenv version 4 and higher |
|
48 | 2 | if (method_exists('Dotenv\\Dotenv','createImmutable')) { |
|
49 | $this->dotenv = DotenvLib::createImmutable(dirname($this->file), basename($this->file)); |
||
50 | } else { |
||
51 | $this->dotenv = DotenvLib::create(dirname($this->file), basename($this->file)); |
||
|
|||
52 | } |
||
53 | $this->dotenv->load(); |
||
54 | } |
||
55 | |||
56 | 1 | /** |
|
57 | * Return a value for a given path. |
||
58 | 1 | * |
|
59 | * @param string $path |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getValue(string $path) : string |
||
65 | } |
||
66 | } |
||
67 |