Completed
Push — master ( 281eb8...04fe01 )
by Sebastian
10:51
created

Dotenv   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 40
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 6 1
A getValue() 0 4 1
1
<?php
2
namespace phpbu\App\Adapter;
3
4
use Dotenv\Dotenv as DotenvLib;
5
use phpbu\App\Adapter;
6
use phpbu\App\Util;
7
8
/**
9
 * Dotenv Adapter
10
 *
11
 * @package    phpbu
12
 * @subpackage App
13
 * @author     Sebastian Feldmann <[email protected]>
14
 * @copyright  Sebastian Feldmann <[email protected]>
15
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
16
 * @link       http://phpbu.de/
17
 * @since      Class available since Release 4.0.0
18
 */
19
class Dotenv implements Adapter
20
{
21
    /**
22
     * Path to the .env file
23
     *
24
     * @var string
25
     */
26
    private $file;
27
28
    /**
29
     * Actual dot env reader
30
     *
31
     * @var \Dotenv\Dotenv
32
     */
33
    private $dotenv;
34
35
    /**
36
     * Setup the adapter.
37
     *
38
     * @param  array $conf
39
     * @return void
40
     */
41
    public function setup(array $conf)
42
    {
43
        $this->file   = Util\Arr::getValue($conf, 'file', '.env');
44
        $this->dotenv = new DotenvLib(dirname($this->file), basename($this->file));
45
        $this->dotenv->load();
46
    }
47
48
    /**
49
     * Return a value for a given path.
50
     *
51
     * @param  string $path
52
     * @return string
53
     */
54
    public function getValue($path)
55
    {
56
        return getenv($path);
57
    }
58
}
59