Passed
Pull Request — master (#39)
by Daniel
03:37
created

ConfigFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getConfig() 0 7 2
1
<?php
2
3
namespace Jellyfish\Config;
4
5
class ConfigFactory
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $appDir;
11
12
    /**
13
     * @var string
14
     */
15
    protected $environment;
16
17
    /**
18
     * @var \Jellyfish\Config\ConfigInterface
19
     */
20
    protected $config;
21
22
    /**
23
     * @param string $appDir
24
     * @param string $environment
25
     */
26
    public function __construct(
27
        string $appDir,
28
        string $environment
29
    ) {
30
        $this->appDir = $appDir;
31
        $this->environment = $environment;
32
    }
33
34
    /**
35
     * @return \Jellyfish\Config\ConfigInterface
36
     */
37
    public function getConfig(): ConfigInterface
38
    {
39
        if ($this->config === null) {
40
            $this->config = new Config($this->appDir, $this->environment);
41
        }
42
43
        return $this->config;
44
    }
45
}
46