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