Completed
Branch master (ed410a)
by Mariano
03:14
created

Mapping   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 90%

Importance

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