Mapping::addMapping()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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