Completed
Push — master ( e01179...af87ea )
by Thomas
02:26
created

LogicTreeFacade::executeCombineConditionsFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
rs 10
c 2
b 1
f 0
1
<?php
2
/**
3
 * Copyright © 2018 Thomas Klein, All rights reserved.
4
 * See LICENSE bundled with this library for license details.
5
 */
6
declare(strict_types=1);
7
8
namespace LogicTree;
9
10
use LogicTree\Node\NodeInterface;
11
use LogicTree\Operator\OperatorInterface;
12
use LogicTree\Operator\OperatorPool;
13
use LogicTree\Service\ConditionManager;
14
15
class LogicTreeFacade
16
{
17
    /**
18
     * @var ConditionManager
19
     */
20
    private $conditionManager;
21
22
    /**
23
     * @var OperatorPool
24
     */
25
    private $operatorPool;
26
27
    public function __construct(?ConditionManager $conditionManager = null)
28
    {
29
        $this->operatorPool = new OperatorPool();
30
        $this->conditionManager = $conditionManager ?? new ConditionManager($this->operatorPool);
31
    }
32
33
    public function addOperator(string $type, string $operatorCode, OperatorInterface $operator): LogicTreeFacade
34
    {
35
        $this->operatorPool->addOperator($type, $operatorCode, $operator);
36
        return $this;
37
    }
38
39
    public function createDataSource(iterable $data): DataSource
40
    {
41
        return new DataSource($data);
42
    }
43
44
    public function executeCombineConditions(NodeInterface $node, DataSource $dataSource): bool
45
    {
46
        return $this->conditionManager->execute($node, $dataSource);
47
    }
48
}
49