1 | <?php |
||
21 | class BooleanNode extends AbstractNode |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $operator; |
||
28 | |||
29 | /** |
||
30 | * @var AbstractNode |
||
31 | */ |
||
32 | protected $leftSide; |
||
33 | |||
34 | /** |
||
35 | * @var AbstractNode |
||
36 | */ |
||
37 | protected $rightSide; |
||
38 | |||
39 | /** |
||
40 | * Constructor. |
||
41 | * |
||
42 | * @param AbstractNode $leftSide Left side of the boolean expression. |
||
43 | * @param AbstractNode $rightSide Right side of the boolean expression. |
||
44 | * @param string $operator One of the `ConditionParser::LOGICAL_*` constants. |
||
45 | */ |
||
46 | public function __construct(AbstractNode $leftSide, AbstractNode $rightSide, $operator) |
||
52 | |||
53 | /** |
||
54 | * @inheritdoc |
||
55 | */ |
||
56 | public function getCssResult() |
||
60 | |||
61 | /** |
||
62 | * @inheritdoc |
||
63 | */ |
||
64 | public function getJavaScriptResult() |
||
68 | |||
69 | /** |
||
70 | * @inheritdoc |
||
71 | */ |
||
72 | public function getPhpResult() |
||
76 | |||
77 | /** |
||
78 | * Global function to get the result of a logical operation, the processor |
||
79 | * does not matter. |
||
80 | * |
||
81 | * @param string $logicalAndFunction Name of the internal function called for a logical "and" operation. |
||
82 | * @param string $logicalOrFunction Name of the internal function called for a logical "or" operation. |
||
83 | * @return null |
||
84 | * @throws \Exception |
||
85 | */ |
||
86 | protected function getLogicalResult($logicalAndFunction, $logicalOrFunction) |
||
101 | |||
102 | /** |
||
103 | * Will process a logical "and" operation on the two given nodes. The result |
||
104 | * will be an array containing all the result of the "and" operation on |
||
105 | * every existing results of the two nodes. |
||
106 | * |
||
107 | * With CSS, it means to concatenate two condition strings. Example: |
||
108 | * |
||
109 | * Left = [foo="bar"] |
||
110 | * Right = [pet="dog"] |
||
111 | * Result = [foo="bar"][pet="dog"] |
||
112 | * |
||
113 | * @param AbstractNode $left Left node instance. |
||
114 | * @param AbstractNode $right Right node instance. |
||
115 | * @return array |
||
116 | */ |
||
117 | protected function processLogicalAndCss(AbstractNode $left, AbstractNode $right) |
||
131 | |||
132 | /** |
||
133 | * Will process a logical "or" operation on the two given nodes. The result |
||
134 | * will be an array containing all the result of the "or" operation on |
||
135 | * every existing results of the two nodes. |
||
136 | * |
||
137 | * @param AbstractNode $left Left node instance. |
||
138 | * @param AbstractNode $right Right node instance. |
||
139 | * @return array |
||
140 | */ |
||
141 | protected function processLogicalOrCss(AbstractNode $left, AbstractNode $right) |
||
148 | |||
149 | /** |
||
150 | * Will process a logical "and" operation on the two given nodes. The result |
||
151 | * will be an array containing all the result of the "and" operation on |
||
152 | * every existing results of the two nodes. |
||
153 | * |
||
154 | * With JavaScript, it means adding the operator `&&` between the two |
||
155 | * expressions. |
||
156 | * |
||
157 | * @param AbstractNode $left Left node instance. |
||
158 | * @param AbstractNode $right Right node instance. |
||
159 | * @return array |
||
160 | */ |
||
161 | protected function processLogicalAndJavaScript(AbstractNode $left, AbstractNode $right) |
||
175 | |||
176 | /** |
||
177 | * Will process a logical "or" operation on the two given nodes. The result |
||
178 | * will be an array containing all the result of the "or" operation on |
||
179 | * every existing results of the two nodes. |
||
180 | * |
||
181 | * @param AbstractNode $left Left node instance. |
||
182 | * @param AbstractNode $right Right node instance. |
||
183 | * @return array |
||
184 | */ |
||
185 | protected function processLogicalOrJavaScript(AbstractNode $left, AbstractNode $right) |
||
192 | |||
193 | /** |
||
194 | * Will process a logical "and" operation on the two given nodes. The result |
||
195 | * will be an array containing all the result of the "and" operation on |
||
196 | * every existing results of the two nodes. |
||
197 | * |
||
198 | * With JavaScript, it means that the left and the right nodes are both |
||
199 | * true. |
||
200 | * |
||
201 | * @param AbstractNode $left Left node instance. |
||
202 | * @param AbstractNode $right Right node instance. |
||
203 | * @return bool |
||
204 | */ |
||
205 | protected function processLogicalAndPhp(AbstractNode $left, AbstractNode $right) |
||
209 | |||
210 | /** |
||
211 | * Will process a logical "or" operation on the two given nodes. |
||
212 | * |
||
213 | * @param AbstractNode $left Left node instance. |
||
214 | * @param AbstractNode $right Right node instance. |
||
215 | * @return bool |
||
216 | */ |
||
217 | protected function processLogicalOrPhp(AbstractNode $left, AbstractNode $right) |
||
221 | } |
||
222 |