Completed
Push — master ( 2e4917...2e950a )
by Klaus
19:05 queued 19:05
created

CompileNode   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 0
dl 0
loc 71
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Component\RuleEngine\Ast;
6
7
use Linio\Common\Type\Dictionary;
8
9
class CompileNode
10
{
11
    /**
12
     * @var Node[]
13
     */
14
    protected array $children = [];
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
15
    protected Dictionary $context;
16
17
    public function __construct()
18
    {
19
        $this->context = new Dictionary();
20
    }
21
22
    /**
23
     * @return Node[]
24
     */
25
    public function getChildren(): array
26
    {
27
        return $this->children;
28
    }
29
30
    /**
31
     * @param Node[] $children
32
     */
33
    public function setChildren(array $children): void
34
    {
35
        $this->children = $children;
36
    }
37
38
    public function addChild(Node $node): void
39
    {
40
        $this->children[] = $node;
41
    }
42
43
    /**
44
     * @param Node[] $nodes
45
     */
46
    public function addChildren(array $nodes): void
47
    {
48
        $this->children = array_merge($this->children, $nodes);
49
    }
50
51
    public function getContext(): Dictionary
52
    {
53
        return $this->context;
54
    }
55
56
    public function setContext(Dictionary $context): void
57
    {
58
        $this->context = $context;
59
    }
60
61
    public function evaluate()
62
    {
63
        foreach ($this->children as $child) {
64
            $child->evaluate();
65
        }
66
67
        return null;
68
    }
69
}
70