ConditionsMatcherFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0
ccs 10
cts 11
cp 0.9091
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A get() 0 10 2
1
<?php
2
3
namespace Mcustiel\PowerRoute\Common\Conditions;
4
5
use Mcustiel\PowerRoute\Common\Factories\InputSourceFactory;
6
use Mcustiel\PowerRoute\Common\Factories\MatcherFactory;
7
8
class ConditionsMatcherFactory
9
{
10
    private $conditionMatchersMap = [
11
        'allConditionsMatcher' => AllConditionsMatcher::class,
12
        'oneConditionsMatcher' => OneConditionMatcher::class,
13
    ];
14
15
    private $inputSouceFactory;
16
    private $matcherFactory;
17
18 3
    public function __construct(
19
        InputSourceFactory $inputSouceFactory,
20
        MatcherFactory $matcherFactory
21
    ) {
22 3
        $this->inputSouceFactory = $inputSouceFactory;
23 3
        $this->matcherFactory = $matcherFactory;
24 3
    }
25
26 3
    public function get($name)
27
    {
28 3
        if (isset($this->conditionMatchersMap[$name])) {
29 3
            return new $this->conditionMatchersMap[$name](
30 3
                $this->inputSouceFactory,
31 3
                $this->matcherFactory
32 3
            );
33
        }
34
        throw new \RuntimeException('Invalid condition matcher specified');
35
    }
36
}
37