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

ConditionsMatcherFactory   A

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 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 29
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
namespace Mcustiel\PowerRoute\Common\Conditions;
3
4
use Mcustiel\PowerRoute\Common\Factories\InputSourceFactory;
5
use Mcustiel\PowerRoute\Common\Factories\MatcherFactory;
6
7
class ConditionsMatcherFactory
8
{
9
    private $conditionMatchersMap = [
10
        'allConditionsMatcher' => AllConditionsMatcher::class,
11
        'oneConditionsMatcher' => OneConditionMatcher::class
12
    ];
13
14
    private $inputSouceFactory;
15
    private $matcherFactory;
16
17 3
    public function __construct(
18
        InputSourceFactory $inputSouceFactory,
19
        MatcherFactory $matcherFactory
20
    ) {
21 3
        $this->inputSouceFactory = $inputSouceFactory;
22 3
        $this->matcherFactory = $matcherFactory;
23 3
    }
24
25 3
    public function get($id)
26
    {
27 3
        if (isset($this->conditionMatchersMap[$id])) {
28 3
            return new $this->conditionMatchersMap[$id](
29 3
                $this->inputSouceFactory,
30 3
                $this->matcherFactory
31 3
            );
32
        }
33
        throw new \RuntimeException('Invalid condition matcher specified');
34
    }
35
}
36