Completed
Branch conditions-refactoring (7efd7c)
by Romain
01:49
created

ConditionTree::getPhpResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/*
3
 * 2016 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 Formz project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\Condition\Parser;
15
16
use Romm\Formz\Condition\Parser\Node\NodeInterface;
17
use Romm\Formz\Condition\Processor\ConditionProcessor;
18
use Romm\Formz\Condition\Processor\DataObject\PhpConditionDataObject;
19
use TYPO3\CMS\Extbase\Error\Result;
20
21
/**
22
 * @todo
23
 */
24
class ConditionTree
25
{
26
    /**
27
     * @var NodeInterface
28
     */
29
    private $rootNode;
30
31
    /**
32
     * @var Result
33
     */
34
    private $result;
35
36
    /**
37
     * @var ConditionProcessor
38
     */
39
    private $conditionProcessor;
40
41
    /**
42
     * @param NodeInterface $rootNode
43
     * @param Result        $result
44
     */
45
    public function __construct(NodeInterface $rootNode, Result $result)
46
    {
47
        $this->rootNode = $rootNode;
48
        $this->result = $result;
49
50
        $this->rootNode->setTree($this);
51
    }
52
53
    /**
54
     * @param ConditionProcessor $conditionProcessor
55
     * @return $this
56
     */
57
    public function attachConditionProcessor(ConditionProcessor $conditionProcessor)
58
    {
59
        $this->conditionProcessor = $conditionProcessor;
60
61
        return $this;
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function getCssConditions()
68
    {
69
        return $this->rootNode->getCssResult();
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function getJavaScriptConditions()
76
    {
77
        return $this->rootNode->getJavaScriptResult();
78
    }
79
80
    /**
81
     * @param PhpConditionDataObject $dataObject
82
     * @return bool
83
     */
84
    public function getPhpResult(PhpConditionDataObject $dataObject)
85
    {
86
        return $this->rootNode->getPhpResult($dataObject);
87
    }
88
89
    /**
90
     * @return Result
91
     */
92
    public function getResult()
93
    {
94
        return $this->result;
95
    }
96
97
    /**
98
     * @return ConditionProcessor
99
     */
100
    public function getConditionProcessor()
101
    {
102
        return $this->conditionProcessor;
103
    }
104
}
105