Infrastructure   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 68
ccs 23
cts 23
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addEnvironment() 0 13 2
A addEnvironments() 0 8 2
A getEnvironment() 0 11 2
A getEnvironments() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
namespace Assimtech\Tempo;
4
5
use InvalidArgumentException;
6
use OutOfBoundsException;
7
8
class Infrastructure
9
{
10
    /**
11
     * @var \Assimtech\Tempo\Environment[] $environments
12
     */
13
    private $environments;
14
15 6
    public function __construct()
16
    {
17 6
        $this->environments = array();
18 6
    }
19
20
    /**
21
     * @param \Assimtech\Tempo\Environment $environment
22
     * @return self
23
     * @throws \InvalidArgumentException
24
     */
25 3
    public function addEnvironment(Environment $environment)
26
    {
27 3
        if (isset($this->environments[(string)$environment])) {
28 1
            throw new InvalidArgumentException(sprintf(
29 1
                'Environment: %s already exists',
30
                $environment
31 1
            ));
32
        }
33
34 3
        $this->environments[(string)$environment] = $environment;
35
36 3
        return $this;
37
    }
38
39
    /**
40
     * @param \Assimtech\Tempo\Environment[] $environments
41
     * @return self
42
     */
43 2
    public function addEnvironments($environments)
44
    {
45 2
        foreach ($environments as $environment) {
46 1
            $this->addEnvironment($environment);
47 2
        }
48
49 2
        return $this;
50
    }
51
52
    /**
53
     * @param string $name
54
     * @return \Assimtech\Tempo\Environment
55
     */
56 3
    public function getEnvironment($name)
57
    {
58 3
        if (!isset($this->environments[$name])) {
59 1
            throw new OutOfBoundsException(sprintf(
60 1
                'Environment: %s doesn\'t exist',
61
                $name
62 1
            ));
63
        }
64
65 2
        return $this->environments[$name];
66
    }
67
68
    /**
69
     * @return \Assimtech\Tempo\Environment[]
70
     */
71 1
    public function getEnvironments()
72
    {
73 1
        return $this->environments;
74
    }
75
}
76