5 * Copyright (c) 2006 - 2014 PHPExcel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 * @package PHPExcel_Style
23 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
30 * PHPExcel_Style_Conditional
33 * @package PHPExcel_Style
34 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
36 class PHPExcel_Style_Conditional
implements PHPExcel_IComparable
39 const CONDITION_NONE
= 'none';
40 const CONDITION_CELLIS
= 'cellIs';
41 const CONDITION_CONTAINSTEXT
= 'containsText';
42 const CONDITION_EXPRESSION
= 'expression';
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';
63 private $_conditionType;
70 private $_operatorType;
84 private $_condition = array();
94 * Create a new PHPExcel_Style_Conditional
96 public function __construct()
99 $this->_conditionType
= PHPExcel_Style_Conditional
::CONDITION_NONE
;
100 $this->_operatorType
= PHPExcel_Style_Conditional
::OPERATOR_NONE
;
102 $this->_condition
= array();
103 $this->_style
= new PHPExcel_Style(FALSE, TRUE);
111 public function getConditionType() {
112 return $this->_conditionType
;
118 * @param string $pValue PHPExcel_Style_Conditional condition type
119 * @return PHPExcel_Style_Conditional
121 public function setConditionType($pValue = PHPExcel_Style_Conditional
::CONDITION_NONE
) {
122 $this->_conditionType
= $pValue;
131 public function getOperatorType() {
132 return $this->_operatorType
;
138 * @param string $pValue PHPExcel_Style_Conditional operator type
139 * @return PHPExcel_Style_Conditional
141 public function setOperatorType($pValue = PHPExcel_Style_Conditional
::OPERATOR_NONE
) {
142 $this->_operatorType
= $pValue;
151 public function getText() {
158 * @param string $value
159 * @return PHPExcel_Style_Conditional
161 public function setText($value = null) {
162 $this->_text
= $value;
169 * @deprecated Deprecated, use getConditions instead
172 public function getCondition() {
173 if (isset($this->_condition
[0])) {
174 return $this->_condition
[0];
183 * @deprecated Deprecated, use setConditions instead
184 * @param string $pValue Condition
185 * @return PHPExcel_Style_Conditional
187 public function setCondition($pValue = '') {
188 if (!is_array($pValue))
189 $pValue = array($pValue);
191 return $this->setConditions($pValue);
199 public function getConditions() {
200 return $this->_condition
;
206 * @param string[] $pValue Condition
207 * @return PHPExcel_Style_Conditional
209 public function setConditions($pValue) {
210 if (!is_array($pValue))
211 $pValue = array($pValue);
213 $this->_condition
= $pValue;
220 * @param string $pValue Condition
221 * @return PHPExcel_Style_Conditional
223 public function addCondition($pValue = '') {
224 $this->_condition
[] = $pValue;
231 * @return PHPExcel_Style
233 public function getStyle() {
234 return $this->_style
;
240 * @param PHPExcel_Style $pValue
241 * @throws PHPExcel_Exception
242 * @return PHPExcel_Style_Conditional
244 public function setStyle(PHPExcel_Style
$pValue = null) {
245 $this->_style
= $pValue;
252 * @return string Hash code
254 public function getHashCode() {
256 $this->_conditionType
257 . $this->_operatorType
258 . implode(';', $this->_condition
)
259 . $this->_style
->getHashCode()
265 * Implement PHP __clone to create a deep clone, not just a shallow copy.
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;
273 $this->$key = $value;