1 | <?php |
||
22 | class BooleanNode extends AbstractNode |
||
23 | { |
||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $operator; |
||
28 | |||
29 | /** |
||
30 | * @var NodeInterface |
||
31 | */ |
||
32 | protected $leftSide; |
||
33 | |||
34 | /** |
||
35 | * @var NodeInterface |
||
36 | */ |
||
37 | protected $rightSide; |
||
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) |
||
64 | |||
65 | /** |
||
66 | * @inheritdoc |
||
67 | */ |
||
68 | public function getCssResult() |
||
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | public function getJavaScriptResult() |
||
94 | |||
95 | /** |
||
96 | * @inheritdoc |
||
97 | */ |
||
98 | public function getPhpResult(PhpConditionDataObject $dataObject) |
||
109 | |||
110 | /** |
||
111 | * Global function to get the result of a logical operation, the processor |
||
112 | * does not matter. |
||
113 | * |
||
114 | * @param callable $logicalAndFunction |
||
115 | * @param callable $logicalOrFunction |
||
116 | * @return null |
||
117 | * @throws \Exception |
||
118 | */ |
||
119 | protected function getLogicalResult(callable $logicalAndFunction, callable $logicalOrFunction) |
||
134 | |||
135 | /** |
||
136 | * Will process a logical "and" operation on the two given nodes. The result |
||
137 | * will be an array containing all the result of the "and" operation on |
||
138 | * every existing results of the two nodes. |
||
139 | * |
||
140 | * With CSS, it means to concatenate two condition strings. Example: |
||
141 | * |
||
142 | * Left = [foo="bar"] |
||
143 | * Right = [pet="dog"] |
||
144 | * Result = [foo="bar"][pet="dog"] |
||
145 | * |
||
146 | * @param NodeInterface $left Left node instance. |
||
147 | * @param NodeInterface $right Right node instance. |
||
148 | * @return array |
||
149 | */ |
||
150 | protected function processLogicalAndCss(NodeInterface $left, NodeInterface $right) |
||
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 | * @param NodeInterface $left Left node instance. |
||
171 | * @param NodeInterface $right Right node instance. |
||
172 | * @return array |
||
173 | */ |
||
174 | protected function processLogicalOrCss(NodeInterface $left, NodeInterface $right) |
||
181 | |||
182 | /** |
||
183 | * Will process a logical "and" operation on the two given nodes. The result |
||
184 | * will be an array containing all the result of the "and" operation on |
||
185 | * every existing results of the two nodes. |
||
186 | * |
||
187 | * With JavaScript, it means adding the operator `&&` between the two |
||
188 | * expressions. |
||
189 | * |
||
190 | * @param NodeInterface $left Left node instance. |
||
191 | * @param NodeInterface $right Right node instance. |
||
192 | * @return array |
||
193 | */ |
||
194 | protected function processLogicalAndJavaScript(NodeInterface $left, NodeInterface $right) |
||
208 | |||
209 | /** |
||
210 | * Will process a logical "or" operation on the two given nodes. The result |
||
211 | * will be an array containing all the result of the "or" operation on |
||
212 | * every existing results of the two nodes. |
||
213 | * |
||
214 | * @param NodeInterface $left Left node instance. |
||
215 | * @param NodeInterface $right Right node instance. |
||
216 | * @return array |
||
217 | */ |
||
218 | protected function processLogicalOrJavaScript(NodeInterface $left, NodeInterface $right) |
||
225 | |||
226 | /** |
||
227 | * Will process a logical "and" operation on the two given nodes. The result |
||
228 | * will be an array containing all the result of the "and" operation on |
||
229 | * every existing results of the two nodes. |
||
230 | * |
||
231 | * With JavaScript, it means that the left and the right nodes are both |
||
232 | * true. |
||
233 | * |
||
234 | * @param NodeInterface $left Left node instance. |
||
235 | * @param NodeInterface $right Right node instance. |
||
236 | * @param PhpConditionDataObject $dataObject |
||
237 | * @return bool |
||
238 | */ |
||
239 | protected function processLogicalAndPhp(NodeInterface $left, NodeInterface $right, PhpConditionDataObject $dataObject) |
||
243 | |||
244 | /** |
||
245 | * Will process a logical "or" operation on the two given nodes. |
||
246 | * |
||
247 | * @param NodeInterface $left Left node instance. |
||
248 | * @param NodeInterface $right Right node instance. |
||
249 | * @param PhpConditionDataObject $dataObject |
||
250 | * @return bool |
||
251 | */ |
||
252 | protected function processLogicalOrPhp(NodeInterface $left, NodeInterface $right, PhpConditionDataObject $dataObject) |
||
256 | } |
||
257 |