Mapping   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
dl 0
loc 21
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
ccs 9
cts 10
cp 0.9
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addMapping() 0 4 1
A checkMappingIsValid() 0 6 2
1
<?php
2
3
namespace Mcustiel\PowerRoute\Common\Factories;
4
5
use Mcustiel\Creature\CreatorInterface;
6
7
class Mapping
8
{
9
    protected $mapping = [];
10
11 4
    public function __construct(array $mapping)
12
    {
13 4
        $this->mapping = array_merge($this->mapping, $mapping);
14 4
    }
15
16 3
    public function addMapping($identifier, CreatorInterface $creator)
17
    {
18 3
        $this->mapping[$identifier] = $creator;
19 3
    }
20
21 4
    protected function checkMappingIsValid($mapping)
22
    {
23 4
        if (!isset($this->mapping[$mapping])) {
24
            throw new \Exception("Did not find a mapped class identified by $mapping");
25
        }
26 4
    }
27
}
28