EnvironmentManager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setEnv() 0 4 1
A getEnv() 0 4 1
A setEnvInstance() 0 4 1
A getEnvInstance() 0 8 2
1
<?php
2
/*
3
 * This file is part of the Borobudur-Kernel package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\Kernel;
12
13
use Borobudur\Kernel\Exception\RuntimeException;
14
15
/**
16
 * @author      Iqbal Maulana <[email protected]>
17
 * @created     8/17/15
18
 */
19
class EnvironmentManager
20
{
21
    /**
22
     * @var string
23
     */
24
    private $env;
25
26
    /**
27
     * @var EnvironmentInterface
28
     */
29
    private $envInstance;
30
31
    /**
32
     * Constructor.
33
     *
34
     * @param string $env
35
     */
36
    public function __construct($env)
37
    {
38
        $this->env = $env;
39
    }
40
41
    /**
42
     * Set environment.
43
     *
44
     * @param string $env
45
     */
46
    public function setEnv($env)
47
    {
48
        $this->env = $env;
49
    }
50
51
    /**
52
     * Get env.
53
     *
54
     * @return string
55
     */
56
    public function getEnv()
57
    {
58
        return $this->env;
59
    }
60
61
    /**
62
     * Set active env instance.
63
     *
64
     * @param EnvironmentInterface $env
65
     */
66
    public function setEnvInstance(EnvironmentInterface $env)
67
    {
68
        $this->envInstance = $env;
69
    }
70
71
    /**
72
     * Get environment instance.
73
     *
74
     * @return EnvironmentInterface
75
     */
76
    public function getEnvInstance()
77
    {
78
        if (null === $this->envInstance) {
79
            throw new RuntimeException('There are no active environment.');
80
        }
81
82
        return $this->envInstance;
83
    }
84
85
}
86