Passed
Branch develop (905d13)
by Mariano
09:27
created

MatcherFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createFromConfig() 0 7 1
1
<?php
2
namespace Mcustiel\PowerRoute\Common\Factories;
3
4
use Mcustiel\PowerRoute\Matchers as Matchers;
5
6
class MatcherFactory extends Mapping
7
{
8 3
    public function __construct(array $mapping)
9
    {
10 3
        parent::__construct($mapping);
11 3
    }
12
13
    /**
14
     *
15
     * @param array $config
16
     *
17
     * @return \Mcustiel\PowerRoute\Matchers\MatcherInterface
18
     * @throws \Exception
19
     */
20 3
    public function createFromConfig(array $config)
21
    {
22 3
        $class = key($config);
23 3
        $this->checkMappingIsValid($class);
24
25 3
        return new $this->mapping[$class]($config[$class]);
26
    }
27
}
28