ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Conditional.php
Go to the documentation of this file.
1<?php
2
4
7
8class Conditional implements IComparable
9{
10 // Condition types
11 const CONDITION_NONE = 'none';
12 const CONDITION_CELLIS = 'cellIs';
13 const CONDITION_CONTAINSTEXT = 'containsText';
14 const CONDITION_EXPRESSION = 'expression';
15 const CONDITION_CONTAINSBLANKS = 'containsBlanks';
16 const CONDITION_NOTCONTAINSBLANKS = 'notContainsBlanks';
17 const CONDITION_DATABAR = 'dataBar';
18 const CONDITION_NOTCONTAINSTEXT = 'notContainsText';
19
20 private const CONDITION_TYPES = [
29 ];
30
31 // Operator types
32 const OPERATOR_NONE = '';
33 const OPERATOR_BEGINSWITH = 'beginsWith';
34 const OPERATOR_ENDSWITH = 'endsWith';
35 const OPERATOR_EQUAL = 'equal';
36 const OPERATOR_GREATERTHAN = 'greaterThan';
37 const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
38 const OPERATOR_LESSTHAN = 'lessThan';
39 const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
40 const OPERATOR_NOTEQUAL = 'notEqual';
41 const OPERATOR_CONTAINSTEXT = 'containsText';
42 const OPERATOR_NOTCONTAINS = 'notContains';
43 const OPERATOR_BETWEEN = 'between';
44 const OPERATOR_NOTBETWEEN = 'notBetween';
45
52
59
65 private $text;
66
72 private $stopIfTrue = false;
73
79 private $condition = [];
80
84 private $dataBar;
85
91 private $style;
92
96 public function __construct()
97 {
98 // Initialise values
99 $this->style = new Style(false, true);
100 }
101
107 public function getConditionType()
108 {
110 }
111
119 public function setConditionType($pValue)
120 {
121 $this->conditionType = $pValue;
122
123 return $this;
124 }
125
131 public function getOperatorType()
132 {
133 return $this->operatorType;
134 }
135
143 public function setOperatorType($pValue)
144 {
145 $this->operatorType = $pValue;
146
147 return $this;
148 }
149
155 public function getText()
156 {
157 return $this->text;
158 }
159
167 public function setText($value)
168 {
169 $this->text = $value;
170
171 return $this;
172 }
173
179 public function getStopIfTrue()
180 {
181 return $this->stopIfTrue;
182 }
183
191 public function setStopIfTrue($value)
192 {
193 $this->stopIfTrue = $value;
194
195 return $this;
196 }
197
203 public function getConditions()
204 {
205 return $this->condition;
206 }
207
215 public function setConditions($pValue)
216 {
217 if (!is_array($pValue)) {
218 $pValue = [$pValue];
219 }
220 $this->condition = $pValue;
221
222 return $this;
223 }
224
232 public function addCondition($pValue)
233 {
234 $this->condition[] = $pValue;
235
236 return $this;
237 }
238
244 public function getStyle()
245 {
246 return $this->style;
247 }
248
256 public function setStyle(?Style $pValue = null)
257 {
258 $this->style = $pValue;
259
260 return $this;
261 }
262
268 public function getDataBar()
269 {
270 return $this->dataBar;
271 }
272
279 {
280 $this->dataBar = $dataBar;
281
282 return $this;
283 }
284
290 public function getHashCode()
291 {
292 return md5(
293 $this->conditionType .
294 $this->operatorType .
295 implode(';', $this->condition) .
296 $this->style->getHashCode() .
297 __CLASS__
298 );
299 }
300
304 public function __clone()
305 {
306 $vars = get_object_vars($this);
307 foreach ($vars as $key => $value) {
308 if (is_object($value)) {
309 $this->$key = clone $value;
310 } else {
311 $this->$key = $value;
312 }
313 }
314 }
315
319 public static function isValidConditionType(string $type): bool
320 {
321 return in_array($type, self::CONDITION_TYPES);
322 }
323}
An exception for terminatinating execution or to throw for unit testing.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
setDataBar(ConditionalDataBar $dataBar)
set DataBar.
setStyle(?Style $pValue=null)
Set Style.
setConditionType($pValue)
Set Condition type.
static isValidConditionType(string $type)
Verify if param is valid condition type.
setOperatorType($pValue)
Set Operator type.
__construct()
Create a new Conditional.
Definition: Conditional.php:96
$key
Definition: croninfo.php:18
$type