Mapping::checkMappingIsValid()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

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