PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.8
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.8
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Style / Conditional.php

Conditional.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.8, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php

273 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Style;
4
5 use PhpOffice\PhpSpreadsheet\IComparable;
6
7 class Conditional implements IComparable
8 {
9 // Condition types
10 const CONDITION_NONE = 'none';
11 const CONDITION_CELLIS = 'cellIs';
12 const CONDITION_CONTAINSTEXT = 'containsText';
13 const CONDITION_EXPRESSION = 'expression';
14 const CONDITION_CONTAINSBLANKS = 'containsBlanks';
15
16 // Operator types
17 const OPERATOR_NONE = '';
18 const OPERATOR_BEGINSWITH = 'beginsWith';
19 const OPERATOR_ENDSWITH = 'endsWith';
20 const OPERATOR_EQUAL = 'equal';
21 const OPERATOR_GREATERTHAN = 'greaterThan';
22 const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
23 const OPERATOR_LESSTHAN = 'lessThan';
24 const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
25 const OPERATOR_NOTEQUAL = 'notEqual';
26 const OPERATOR_CONTAINSTEXT = 'containsText';
27 const OPERATOR_NOTCONTAINS = 'notContains';
28 const OPERATOR_BETWEEN = 'between';
29
30 /**
31 * Condition type.
32 *
33 * @var string
34 */
35 private $conditionType = self::CONDITION_NONE;
36
37 /**
38 * Operator type.
39 *
40 * @var string
41 */
42 private $operatorType = self::OPERATOR_NONE;
43
44 /**
45 * Text.
46 *
47 * @var string
48 */
49 private $text;
50
51 /**
52 * Stop on this condition, if it matches.
53 *
54 * @var bool
55 */
56 private $stopIfTrue = false;
57
58 /**
59 * Condition.
60 *
61 * @var string[]
62 */
63 private $condition = [];
64
65 /**
66 * Style.
67 *
68 * @var Style
69 */
70 private $style;
71
72 /**
73 * Create a new Conditional.
74 */
75 public function __construct()
76 {
77 // Initialise values
78 $this->style = new Style(false, true);
79 }
80
81 /**
82 * Get Condition type.
83 *
84 * @return string
85 */
86 public function getConditionType()
87 {
88 return $this->conditionType;
89 }
90
91 /**
92 * Set Condition type.
93 *
94 * @param string $pValue Condition type, see self::CONDITION_*
95 *
96 * @return Conditional
97 */
98 public function setConditionType($pValue)
99 {
100 $this->conditionType = $pValue;
101
102 return $this;
103 }
104
105 /**
106 * Get Operator type.
107 *
108 * @return string
109 */
110 public function getOperatorType()
111 {
112 return $this->operatorType;
113 }
114
115 /**
116 * Set Operator type.
117 *
118 * @param string $pValue Conditional operator type, see self::OPERATOR_*
119 *
120 * @return Conditional
121 */
122 public function setOperatorType($pValue)
123 {
124 $this->operatorType = $pValue;
125
126 return $this;
127 }
128
129 /**
130 * Get text.
131 *
132 * @return string
133 */
134 public function getText()
135 {
136 return $this->text;
137 }
138
139 /**
140 * Set text.
141 *
142 * @param string $value
143 *
144 * @return Conditional
145 */
146 public function setText($value)
147 {
148 $this->text = $value;
149
150 return $this;
151 }
152
153 /**
154 * Get StopIfTrue.
155 *
156 * @return bool
157 */
158 public function getStopIfTrue()
159 {
160 return $this->stopIfTrue;
161 }
162
163 /**
164 * Set StopIfTrue.
165 *
166 * @param bool $value
167 *
168 * @return Conditional
169 */
170 public function setStopIfTrue($value)
171 {
172 $this->stopIfTrue = $value;
173
174 return $this;
175 }
176
177 /**
178 * Get Conditions.
179 *
180 * @return string[]
181 */
182 public function getConditions()
183 {
184 return $this->condition;
185 }
186
187 /**
188 * Set Conditions.
189 *
190 * @param string[] $pValue Condition
191 *
192 * @return Conditional
193 */
194 public function setConditions($pValue)
195 {
196 if (!is_array($pValue)) {
197 $pValue = [$pValue];
198 }
199 $this->condition = $pValue;
200
201 return $this;
202 }
203
204 /**
205 * Add Condition.
206 *
207 * @param string $pValue Condition
208 *
209 * @return Conditional
210 */
211 public function addCondition($pValue)
212 {
213 $this->condition[] = $pValue;
214
215 return $this;
216 }
217
218 /**
219 * Get Style.
220 *
221 * @return Style
222 */
223 public function getStyle()
224 {
225 return $this->style;
226 }
227
228 /**
229 * Set Style.
230 *
231 * @param Style $pValue
232 *
233 * @return Conditional
234 */
235 public function setStyle(Style $pValue = null)
236 {
237 $this->style = $pValue;
238
239 return $this;
240 }
241
242 /**
243 * Get hash code.
244 *
245 * @return string Hash code
246 */
247 public function getHashCode()
248 {
249 return md5(
250 $this->conditionType .
251 $this->operatorType .
252 implode(';', $this->condition) .
253 $this->style->getHashCode() .
254 __CLASS__
255 );
256 }
257
258 /**
259 * Implement PHP __clone to create a deep clone, not just a shallow copy.
260 */
261 public function __clone()
262 {
263 $vars = get_object_vars($this);
264 foreach ($vars as $key => $value) {
265 if (is_object($value)) {
266 $this->$key = clone $value;
267 } else {
268 $this->$key = $value;
269 }
270 }
271 }
272 }
273