Completed
Branch develop (4c3d66)
by Mariano
11:18
created

Mapping   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 92.86%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 31
wmc 6
lcom 1
cbo 0
ccs 13
cts 14
cp 0.9286
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A checkMappingIsValid() 0 6 2
A addMapping() 0 4 1
A getClassName() 0 4 1
A getConstructorArguments() 0 4 1
1
<?php
2
namespace Mcustiel\PowerRoute\Common\Factories;
3
4
class Mapping
5
{
6
    protected $mapping = [];
7
8 4
    public function __construct(array $mapping)
9
    {
10 4
        $this->mapping = array_merge($this->mapping, $mapping);
11 4
    }
12
13 4
    protected function checkMappingIsValid($mapping)
14
    {
15 4
        if (!isset($this->mapping[$mapping])) {
16
            throw new \Exception();
17
        }
18 4
    }
19
20 3
    public function addMapping($identifier, $classData)
21
    {
22 3
        $this->mapping[$identifier] = $classData;
23 3
    }
24
25 3
    protected function getClassName($classId)
26
    {
27 3
        return $this->mapping[$classId][0];
28
    }
29
30 3
    protected function getConstructorArguments($classId)
31
    {
32 3
        return array_slice($this->mapping[$classId], 1);
33
    }
34
}
35