21
21
* @category PHPExcel
22
22
* @package PHPExcel_Style
23
23
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
24
- * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
24
+ * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25
25
* @version ##VERSION##, ##DATE##
26
26
*/
27
27
35
35
*/
36
36
class PHPExcel_Style_Conditional implements PHPExcel_IComparable
37
37
{
38
- /* Condition types */
39
- const CONDITION_NONE = 'none ' ;
40
- const CONDITION_CELLIS = 'cellIs ' ;
41
- const CONDITION_CONTAINSTEXT = 'containsText ' ;
42
- const CONDITION_EXPRESSION = 'expression ' ;
38
+ /* Condition types */
39
+ const CONDITION_NONE = 'none ' ;
40
+ const CONDITION_CELLIS = 'cellIs ' ;
41
+ const CONDITION_CONTAINSTEXT = 'containsText ' ;
42
+ const CONDITION_EXPRESSION = 'expression ' ;
43
43
44
- /* Operator types */
45
- const OPERATOR_NONE = '' ;
46
- const OPERATOR_BEGINSWITH = 'beginsWith ' ;
47
- const OPERATOR_ENDSWITH = 'endsWith ' ;
48
- const OPERATOR_EQUAL = 'equal ' ;
49
- const OPERATOR_GREATERTHAN = 'greaterThan ' ;
50
- const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual ' ;
51
- const OPERATOR_LESSTHAN = 'lessThan ' ;
52
- const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual ' ;
53
- const OPERATOR_NOTEQUAL = 'notEqual ' ;
54
- const OPERATOR_CONTAINSTEXT = 'containsText ' ;
55
- const OPERATOR_NOTCONTAINS = 'notContains ' ;
56
- const OPERATOR_BETWEEN = 'between ' ;
44
+ /* Operator types */
45
+ const OPERATOR_NONE = '' ;
46
+ const OPERATOR_BEGINSWITH = 'beginsWith ' ;
47
+ const OPERATOR_ENDSWITH = 'endsWith ' ;
48
+ const OPERATOR_EQUAL = 'equal ' ;
49
+ const OPERATOR_GREATERTHAN = 'greaterThan ' ;
50
+ const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual ' ;
51
+ const OPERATOR_LESSTHAN = 'lessThan ' ;
52
+ const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual ' ;
53
+ const OPERATOR_NOTEQUAL = 'notEqual ' ;
54
+ const OPERATOR_CONTAINSTEXT = 'containsText ' ;
55
+ const OPERATOR_NOTCONTAINS = 'notContains ' ;
56
+ const OPERATOR_BETWEEN = 'between ' ;
57
57
58
- /**
59
- * Condition type
60
- *
61
- * @var int
62
- */
63
- private $ _conditionType ;
58
+ /**
59
+ * Condition type
60
+ *
61
+ * @var int
62
+ */
63
+ private $ conditionType ;
64
64
65
- /**
66
- * Operator type
67
- *
68
- * @var int
69
- */
70
- private $ _operatorType ;
65
+ /**
66
+ * Operator type
67
+ *
68
+ * @var int
69
+ */
70
+ private $ operatorType ;
71
71
72
- /**
73
- * Text
74
- *
75
- * @var string
76
- */
77
- private $ _text ;
72
+ /**
73
+ * Text
74
+ *
75
+ * @var string
76
+ */
77
+ private $ text ;
78
78
79
- /**
80
- * Condition
81
- *
82
- * @var string[]
83
- */
84
- private $ _condition = array ();
79
+ /**
80
+ * Condition
81
+ *
82
+ * @var string[]
83
+ */
84
+ private $ condition = array ();
85
85
86
- /**
87
- * Style
88
- *
89
- * @var PHPExcel_Style
90
- */
91
- private $ _style ;
86
+ /**
87
+ * Style
88
+ *
89
+ * @var PHPExcel_Style
90
+ */
91
+ private $ style ;
92
92
93
93
/**
94
94
* Create a new PHPExcel_Style_Conditional
95
95
*/
96
96
public function __construct ()
97
97
{
98
- // Initialise values
99
- $ this ->_conditionType = PHPExcel_Style_Conditional::CONDITION_NONE ;
100
- $ this ->_operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE ;
101
- $ this ->_text = null ;
102
- $ this ->_condition = array ();
103
- $ this ->_style = new PHPExcel_Style (FALSE , TRUE );
98
+ // Initialise values
99
+ $ this ->conditionType = PHPExcel_Style_Conditional::CONDITION_NONE ;
100
+ $ this ->operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE ;
101
+ $ this ->text = null ;
102
+ $ this ->condition = array ();
103
+ $ this ->style = new PHPExcel_Style (false , true );
104
104
}
105
105
106
106
/**
107
107
* Get Condition type
108
108
*
109
109
* @return string
110
110
*/
111
- public function getConditionType () {
112
- return $ this ->_conditionType ;
111
+ public function getConditionType ()
112
+ {
113
+ return $ this ->conditionType ;
113
114
}
114
115
115
116
/**
116
117
* Set Condition type
117
118
*
118
- * @param string $pValue PHPExcel_Style_Conditional condition type
119
+ * @param string $pValue PHPExcel_Style_Conditional condition type
119
120
* @return PHPExcel_Style_Conditional
120
121
*/
121
- public function setConditionType ($ pValue = PHPExcel_Style_Conditional::CONDITION_NONE ) {
122
- $ this ->_conditionType = $ pValue ;
123
- return $ this ;
122
+ public function setConditionType ($ pValue = PHPExcel_Style_Conditional::CONDITION_NONE )
123
+ {
124
+ $ this ->conditionType = $ pValue ;
125
+ return $ this ;
124
126
}
125
127
126
128
/**
127
129
* Get Operator type
128
130
*
129
131
* @return string
130
132
*/
131
- public function getOperatorType () {
132
- return $ this ->_operatorType ;
133
+ public function getOperatorType ()
134
+ {
135
+ return $ this ->operatorType ;
133
136
}
134
137
135
138
/**
136
139
* Set Operator type
137
140
*
138
- * @param string $pValue PHPExcel_Style_Conditional operator type
141
+ * @param string $pValue PHPExcel_Style_Conditional operator type
139
142
* @return PHPExcel_Style_Conditional
140
143
*/
141
- public function setOperatorType ($ pValue = PHPExcel_Style_Conditional::OPERATOR_NONE ) {
142
- $ this ->_operatorType = $ pValue ;
143
- return $ this ;
144
+ public function setOperatorType ($ pValue = PHPExcel_Style_Conditional::OPERATOR_NONE )
145
+ {
146
+ $ this ->operatorType = $ pValue ;
147
+ return $ this ;
144
148
}
145
149
146
150
/**
147
151
* Get text
148
152
*
149
153
* @return string
150
154
*/
151
- public function getText () {
152
- return $ this ->_text ;
155
+ public function getText ()
156
+ {
157
+ return $ this ->text ;
153
158
}
154
159
155
160
/**
@@ -158,9 +163,10 @@ public function getText() {
158
163
* @param string $value
159
164
* @return PHPExcel_Style_Conditional
160
165
*/
161
- public function setText ($ value = null ) {
162
- $ this ->_text = $ value ;
163
- return $ this ;
166
+ public function setText ($ value = null )
167
+ {
168
+ $ this ->text = $ value ;
169
+ return $ this ;
164
170
}
165
171
166
172
/**
@@ -169,109 +175,119 @@ public function setText($value = null) {
169
175
* @deprecated Deprecated, use getConditions instead
170
176
* @return string
171
177
*/
172
- public function getCondition () {
173
- if (isset ($ this ->_condition [0 ])) {
174
- return $ this ->_condition [0 ];
175
- }
178
+ public function getCondition ()
179
+ {
180
+ if (isset ($ this ->condition [0 ])) {
181
+ return $ this ->condition [0 ];
182
+ }
176
183
177
- return '' ;
184
+ return '' ;
178
185
}
179
186
180
187
/**
181
188
* Set Condition
182
189
*
183
190
* @deprecated Deprecated, use setConditions instead
184
- * @param string $pValue Condition
191
+ * @param string $pValue Condition
185
192
* @return PHPExcel_Style_Conditional
186
193
*/
187
- public function setCondition ($ pValue = '' ) {
188
- if (!is_array ($ pValue ))
189
- $ pValue = array ($ pValue );
194
+ public function setCondition ($ pValue = '' )
195
+ {
196
+ if (!is_array ($ pValue )) {
197
+ $ pValue = array ($ pValue );
198
+ }
190
199
191
- return $ this ->setConditions ($ pValue );
200
+ return $ this ->setConditions ($ pValue );
192
201
}
193
202
194
203
/**
195
204
* Get Conditions
196
205
*
197
206
* @return string[]
198
207
*/
199
- public function getConditions () {
200
- return $ this ->_condition ;
208
+ public function getConditions ()
209
+ {
210
+ return $ this ->condition ;
201
211
}
202
212
203
213
/**
204
214
* Set Conditions
205
215
*
206
- * @param string[] $pValue Condition
216
+ * @param string[] $pValue Condition
207
217
* @return PHPExcel_Style_Conditional
208
218
*/
209
- public function setConditions ($ pValue ) {
210
- if (!is_array ($ pValue ))
211
- $ pValue = array ($ pValue );
212
-
213
- $ this ->_condition = $ pValue ;
214
- return $ this ;
219
+ public function setConditions ($ pValue )
220
+ {
221
+ if (!is_array ($ pValue )) {
222
+ $ pValue = array ($ pValue );
223
+ }
224
+ $ this ->condition = $ pValue ;
225
+ return $ this ;
215
226
}
216
227
217
228
/**
218
229
* Add Condition
219
230
*
220
- * @param string $pValue Condition
231
+ * @param string $pValue Condition
221
232
* @return PHPExcel_Style_Conditional
222
233
*/
223
- public function addCondition ($ pValue = '' ) {
224
- $ this ->_condition [] = $ pValue ;
225
- return $ this ;
234
+ public function addCondition ($ pValue = '' )
235
+ {
236
+ $ this ->condition [] = $ pValue ;
237
+ return $ this ;
226
238
}
227
239
228
240
/**
229
241
* Get Style
230
242
*
231
243
* @return PHPExcel_Style
232
244
*/
233
- public function getStyle () {
234
- return $ this ->_style ;
245
+ public function getStyle ()
246
+ {
247
+ return $ this ->style ;
235
248
}
236
249
237
250
/**
238
251
* Set Style
239
252
*
240
- * @param PHPExcel_Style $pValue
241
- * @throws PHPExcel_Exception
253
+ * @param PHPExcel_Style $pValue
254
+ * @throws PHPExcel_Exception
242
255
* @return PHPExcel_Style_Conditional
243
256
*/
244
- public function setStyle (PHPExcel_Style $ pValue = null ) {
245
- $ this ->_style = $ pValue ;
246
- return $ this ;
257
+ public function setStyle (PHPExcel_Style $ pValue = null )
258
+ {
259
+ $ this ->style = $ pValue ;
260
+ return $ this ;
247
261
}
248
262
249
- /**
250
- * Get hash code
251
- *
252
- * @return string Hash code
253
- */
254
- public function getHashCode () {
255
- return md5 (
256
- $ this ->_conditionType
257
- . $ this ->_operatorType
258
- . implode ('; ' , $ this ->_condition )
259
- . $ this ->_style ->getHashCode ()
260
- . __CLASS__
261
- );
263
+ /**
264
+ * Get hash code
265
+ *
266
+ * @return string Hash code
267
+ */
268
+ public function getHashCode ()
269
+ {
270
+ return md5 (
271
+ $ this ->conditionType .
272
+ $ this ->operatorType .
273
+ implode ('; ' , $ this ->condition ) .
274
+ $ this ->style ->getHashCode () .
275
+ __CLASS__
276
+ );
262
277
}
263
278
264
- /**
265
- * Implement PHP __clone to create a deep clone, not just a shallow copy.
266
- */
267
- public function __clone () {
268
- $ vars = get_object_vars ($ this );
269
- foreach ($ vars as $ key => $ value ) {
270
- if (is_object ($ value )) {
271
- $ this ->$ key = clone $ value ;
272
- } else {
273
- $ this ->$ key = $ value ;
274
- }
275
- }
276
- }
279
+ /**
280
+ * Implement PHP __clone to create a deep clone, not just a shallow copy.
281
+ */
282
+ public function __clone ()
283
+ {
284
+ $ vars = get_object_vars ($ this );
285
+ foreach ($ vars as $ key => $ value ) {
286
+ if (is_object ($ value )) {
287
+ $ this ->$ key = clone $ value ;
288
+ } else {
289
+ $ this ->$ key = $ value ;
290
+ }
291
+ }
292
+ }
277
293
}
0 commit comments