|
1
|
|
|
<?php |
|
2
|
|
|
namespace Mcustiel\PowerRoute\Common\Conditions; |
|
3
|
|
|
|
|
4
|
|
|
use Mcustiel\PowerRoute\Common\Factories\InputSourceFactory; |
|
5
|
|
|
use Mcustiel\PowerRoute\Common\Factories\MatcherFactory; |
|
6
|
|
|
use Mcustiel\PowerRoute\PowerRoute; |
|
7
|
|
|
use Mcustiel\PowerRoute\Common\ConfigOptions; |
|
8
|
|
|
|
|
9
|
|
|
abstract class AbstractConditionsMatcher |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var \Mcustiel\PowerRoute\Common\Factories\InputSourceFactory |
|
13
|
|
|
*/ |
|
14
|
|
|
private $inputSouceFactory; |
|
15
|
|
|
/** |
|
16
|
|
|
* @var \Mcustiel\PowerRoute\Common\Factories\MatcherFactory |
|
17
|
|
|
*/ |
|
18
|
|
|
private $matcherFactory; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @param \Mcustiel\PowerRoute\Common\Factories\InputSourceFactory $inputSouceFactory |
|
22
|
|
|
* @param \Mcustiel\PowerRoute\Common\Factories\MatcherFactory $matcherFactory |
|
23
|
|
|
*/ |
|
24
|
3 |
|
public function __construct( |
|
25
|
|
|
InputSourceFactory $inputSouceFactory, |
|
26
|
|
|
MatcherFactory $matcherFactory |
|
27
|
|
|
) { |
|
28
|
3 |
|
$this->inputSouceFactory = $inputSouceFactory; |
|
29
|
3 |
|
$this->matcherFactory = $matcherFactory; |
|
30
|
3 |
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param array $condition |
|
34
|
|
|
* |
|
35
|
|
|
* @return \Mcustiel\PowerRoute\Common\Conditions\ClassArgumentObject |
|
36
|
|
|
*/ |
|
37
|
3 |
|
protected function getInputSource(array $condition) |
|
38
|
|
|
{ |
|
39
|
3 |
|
return $this->inputSouceFactory->createFromConfig( |
|
40
|
3 |
|
$condition[ConfigOptions::CONFIG_NODE_CONDITION_SOURCE] |
|
41
|
3 |
|
); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param array $condition |
|
46
|
|
|
* |
|
47
|
|
|
* @return \Mcustiel\PowerRoute\Common\Conditions\ClassArgumentObject |
|
48
|
|
|
*/ |
|
49
|
3 |
|
protected function getMatcher(array $condition) |
|
50
|
|
|
{ |
|
51
|
3 |
|
return $this->matcherFactory->createFromConfig( |
|
52
|
3 |
|
$condition[ConfigOptions::CONFIG_NODE_CONDITION_MATCHER] |
|
53
|
3 |
|
); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|