1 | <?php |
||
22 | class BooleanNode extends AbstractNode |
||
23 | { |
||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $operator; |
||
28 | |||
29 | /** |
||
30 | * @var NodeInterface |
||
31 | */ |
||
32 | protected $leftNode; |
||
33 | |||
34 | /** |
||
35 | * @var NodeInterface |
||
36 | */ |
||
37 | protected $rightNode; |
||
38 | |||
39 | /** |
||
40 | * Constructor. |
||
41 | * |
||
42 | * @param NodeInterface $leftSide Left side of the boolean expression. |
||
43 | * @param NodeInterface $rightSide Right side of the boolean expression. |
||
44 | * @param string $operator One of the `ConditionParser::LOGICAL_*` constants. |
||
45 | */ |
||
46 | public function __construct(NodeInterface $leftSide, NodeInterface $rightSide, $operator) |
||
55 | |||
56 | /** |
||
57 | * @inheritdoc |
||
58 | */ |
||
59 | public function along(callable $callback) |
||
65 | |||
66 | /** |
||
67 | * @inheritdoc |
||
68 | */ |
||
69 | public function getCssResult() |
||
80 | |||
81 | /** |
||
82 | * @inheritdoc |
||
83 | */ |
||
84 | public function getJavaScriptResult() |
||
95 | |||
96 | /** |
||
97 | * @inheritdoc |
||
98 | */ |
||
99 | public function getPhpResult(PhpConditionDataObject $dataObject) |
||
110 | |||
111 | /** |
||
112 | * Global function to get the result of a logical operation, the processor |
||
113 | * does not matter. |
||
114 | * |
||
115 | * @param callable $logicalAndFunction |
||
116 | * @param callable $logicalOrFunction |
||
117 | * @return null |
||
118 | * @throws \Exception |
||
119 | */ |
||
120 | protected function getLogicalResult(callable $logicalAndFunction, callable $logicalOrFunction) |
||
135 | |||
136 | /** |
||
137 | * Will process a logical "and" operation on the two given nodes. The result |
||
138 | * will be an array containing all the result of the "and" operation on |
||
139 | * every existing results of the two nodes. |
||
140 | * |
||
141 | * With CSS, it means to concatenate two condition strings. Example: |
||
142 | * |
||
143 | * Left = [foo="bar"] |
||
144 | * Right = [pet="dog"] |
||
145 | * Result = [foo="bar"][pet="dog"] |
||
146 | * |
||
147 | * @return array |
||
148 | */ |
||
149 | protected function processLogicalAndCss() |
||
163 | |||
164 | /** |
||
165 | * Will process a logical "or" operation on the two given nodes. The result |
||
166 | * will be an array containing all the result of the "or" operation on |
||
167 | * every existing results of the two nodes. |
||
168 | * |
||
169 | * @return array |
||
170 | */ |
||
171 | protected function processLogicalOrCss() |
||
178 | |||
179 | /** |
||
180 | * Will process a logical "and" operation on the two given nodes. The result |
||
181 | * will be an array containing all the result of the "and" operation on |
||
182 | * every existing results of the two nodes. |
||
183 | * |
||
184 | * With JavaScript, it means adding the operator `&&` between the two |
||
185 | * expressions. |
||
186 | * |
||
187 | * @return array |
||
188 | */ |
||
189 | protected function processLogicalAndJavaScript() |
||
203 | |||
204 | /** |
||
205 | * Will process a logical "or" operation on the two given nodes. The result |
||
206 | * will be an array containing all the result of the "or" operation on |
||
207 | * every existing results of the two nodes. |
||
208 | * |
||
209 | * @return array |
||
210 | */ |
||
211 | protected function processLogicalOrJavaScript() |
||
218 | |||
219 | /** |
||
220 | * Will process a logical "and" operation on the two given nodes. The result |
||
221 | * will be an array containing all the result of the "and" operation on |
||
222 | * every existing results of the two nodes. |
||
223 | * |
||
224 | * With JavaScript, it means that the left and the right nodes are both |
||
225 | * true. |
||
226 | * |
||
227 | * @param PhpConditionDataObject $dataObject |
||
228 | * @return bool |
||
229 | */ |
||
230 | protected function processLogicalAndPhp(PhpConditionDataObject $dataObject) |
||
234 | |||
235 | /** |
||
236 | * Will process a logical "or" operation on the two given nodes. |
||
237 | * |
||
238 | * @param PhpConditionDataObject $dataObject |
||
239 | * @return bool |
||
240 | */ |
||
241 | protected function processLogicalOrPhp(PhpConditionDataObject $dataObject) |
||
245 | |||
246 | /** |
||
247 | * @return string |
||
248 | */ |
||
249 | public function getOperator() |
||
253 | } |
||
254 |