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

MatcherFactory::createFromConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 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