Completed
Branch unit-test-asset-handler-connec... (029d08)
by Romain
01:55
created

ConditionNode   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 57
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getCssResult() 0 4 1
A getJavaScriptResult() 0 4 1
A getPhpResult() 0 4 1
A getCondition() 0 4 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\Node;
15
16
use Romm\Formz\Condition\Items\ConditionItemInterface;
17
use Romm\Formz\Condition\Processor\DataObject\PhpConditionDataObject;
18
19
/**
20
 * A condition node, which contains an instance of `ConditionItemInterface`.
21
 */
22
class ConditionNode extends AbstractNode
23
{
24
    /**
25
     * @var string
26
     */
27
    protected $conditionName;
28
29
    /**
30
     * @var ConditionItemInterface
31
     */
32
    protected $condition;
33
34
    /**
35
     * Constructor, which needs a name for the condition and an instance of a
36
     * condition item.
37
     *
38
     * @param string                 $conditionName Name of the condition.
39
     * @param ConditionItemInterface $condition     Instance of the condition item.
40
     */
41
    public function __construct($conditionName, ConditionItemInterface $condition)
42
    {
43
        $this->conditionName = $conditionName;
44
        $this->condition = $condition;
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function getCssResult()
51
    {
52
        return $this->toArray($this->condition->getCssResult());
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public function getJavaScriptResult()
59
    {
60
        return $this->toArray($this->condition->getJavaScriptResult());
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function getPhpResult(PhpConditionDataObject $dataObject)
67
    {
68
        return $this->condition->getPhpResult($dataObject);
69
    }
70
71
    /**
72
     * @return ConditionItemInterface
73
     */
74
    public function getCondition()
75
    {
76
        return $this->condition;
77
    }
78
}
79