← All changes
|
vendor/phpoffice/phpexcel/Classes/PHPExcel/Style/Conditional.php
+131
-147
3.1.1
→
3.0.10
View file →
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * PHPExcel |
| 4 | 4 | * |
| 5 | - * Copyright (c) 2006 - 2015 PHPExcel | |
| 5 | + * Copyright (c) 2006 - 2014 PHPExcel | |
| 6 | 6 | * |
| 7 | 7 | * This library is free software; you can redistribute it and/or |
| 8 | 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | 9 | * License as published by the Free Software Foundation; either |
| @@ -19,10 +19,10 @@ | ||
| 19 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | * |
| 21 | 21 | * @category PHPExcel |
| 22 | 22 | * @package PHPExcel_Style |
| 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 | |
| 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 | 25 | * @version ##VERSION##, ##DATE## |
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | |
| @@ -30,66 +30,66 @@ | ||
| 30 | 30 | * PHPExcel_Style_Conditional |
| 31 | 31 | * |
| 32 | 32 | * @category PHPExcel |
| 33 | 33 | * @package PHPExcel_Style |
| 34 | - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 34 | + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel) | |
| 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 | */ |
| @@ -94,14 +94,14 @@ | ||
| 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 |
| @@ -107,23 +107,21 @@ | ||
| 107 | 107 | * Get Condition type |
| 108 | 108 | * |
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | - public function getConditionType() | |
| 112 | - { | |
| 113 | - return $this->conditionType; | |
| 111 | + public function getConditionType() { | |
| 112 | + return $this->_conditionType; | |
| 114 | 113 | } |
| 115 | 114 | |
| 116 | 115 | /** |
| 117 | 116 | * Set Condition type |
| 118 | 117 | * |
| 119 | - * @param string $pValue PHPExcel_Style_Conditional condition type | |
| 118 | + * @param string $pValue PHPExcel_Style_Conditional condition type | |
| 120 | 119 | * @return PHPExcel_Style_Conditional |
| 121 | 120 | */ |
| 122 | - public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE) | |
| 123 | - { | |
| 124 | - $this->conditionType = $pValue; | |
| 125 | - return $this; | |
| 121 | + public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE) { | |
| 122 | + $this->_conditionType = $pValue; | |
| 123 | + return $this; | |
| 126 | 124 | } |
| 127 | 125 | |
| 128 | 126 | /** |
| 129 | 127 | * Get Operator type |
| @@ -129,23 +127,21 @@ | ||
| 129 | 127 | * Get Operator type |
| 130 | 128 | * |
| 131 | 129 | * @return string |
| 132 | 130 | */ |
| 133 | - public function getOperatorType() | |
| 134 | - { | |
| 135 | - return $this->operatorType; | |
| 131 | + public function getOperatorType() { | |
| 132 | + return $this->_operatorType; | |
| 136 | 133 | } |
| 137 | 134 | |
| 138 | 135 | /** |
| 139 | 136 | * Set Operator type |
| 140 | 137 | * |
| 141 | - * @param string $pValue PHPExcel_Style_Conditional operator type | |
| 138 | + * @param string $pValue PHPExcel_Style_Conditional operator type | |
| 142 | 139 | * @return PHPExcel_Style_Conditional |
| 143 | 140 | */ |
| 144 | - public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE) | |
| 145 | - { | |
| 146 | - $this->operatorType = $pValue; | |
| 147 | - return $this; | |
| 141 | + public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE) { | |
| 142 | + $this->_operatorType = $pValue; | |
| 143 | + return $this; | |
| 148 | 144 | } |
| 149 | 145 | |
| 150 | 146 | /** |
| 151 | 147 | * Get text |
| @@ -151,11 +147,10 @@ | ||
| 151 | 147 | * Get text |
| 152 | 148 | * |
| 153 | 149 | * @return string |
| 154 | 150 | */ |
| 155 | - public function getText() | |
| 156 | - { | |
| 157 | - return $this->text; | |
| 151 | + public function getText() { | |
| 152 | + return $this->_text; | |
| 158 | 153 | } |
| 159 | 154 | |
| 160 | 155 | /** |
| 161 | 156 | * Set text |
| @@ -162,12 +157,11 @@ | ||
| 162 | 157 | * |
| 163 | 158 | * @param string $value |
| 164 | 159 | * @return PHPExcel_Style_Conditional |
| 165 | 160 | */ |
| 166 | - public function setText($value = null) | |
| 167 | - { | |
| 168 | - $this->text = $value; | |
| 169 | - return $this; | |
| 161 | + public function setText($value = null) { | |
| 162 | + $this->_text = $value; | |
| 163 | + return $this; | |
| 170 | 164 | } |
| 171 | 165 | |
| 172 | 166 | /** |
| 173 | 167 | * Get Condition |
| @@ -174,15 +168,14 @@ | ||
| 174 | 168 | * |
| 175 | 169 | * @deprecated Deprecated, use getConditions instead |
| 176 | 170 | * @return string |
| 177 | 171 | */ |
| 178 | - public function getCondition() | |
| 179 | - { | |
| 180 | - if (isset($this->condition[0])) { | |
| 181 | - return $this->condition[0]; | |
| 182 | - } | |
| 172 | + public function getCondition() { | |
| 173 | + if (isset($this->_condition[0])) { | |
| 174 | + return $this->_condition[0]; | |
| 175 | + } | |
| 183 | 176 | |
| 184 | - return ''; | |
| 177 | + return ''; | |
| 185 | 178 | } |
| 186 | 179 | |
| 187 | 180 | /** |
| 188 | 181 | * Set Condition |
| @@ -187,18 +180,16 @@ | ||
| 187 | 180 | /** |
| 188 | 181 | * Set Condition |
| 189 | 182 | * |
| 190 | 183 | * @deprecated Deprecated, use setConditions instead |
| 191 | - * @param string $pValue Condition | |
| 184 | + * @param string $pValue Condition | |
| 192 | 185 | * @return PHPExcel_Style_Conditional |
| 193 | 186 | */ |
| 194 | - public function setCondition($pValue = '') | |
| 195 | - { | |
| 196 | - if (!is_array($pValue)) { | |
| 197 | - $pValue = array($pValue); | |
| 198 | - } | |
| 187 | + public function setCondition($pValue = '') { | |
| 188 | + if (!is_array($pValue)) | |
| 189 | + $pValue = array($pValue); | |
| 199 | 190 | |
| 200 | - return $this->setConditions($pValue); | |
| 191 | + return $this->setConditions($pValue); | |
| 201 | 192 | } |
| 202 | 193 | |
| 203 | 194 | /** |
| 204 | 195 | * Get Conditions |
| @@ -204,38 +195,35 @@ | ||
| 204 | 195 | * Get Conditions |
| 205 | 196 | * |
| 206 | 197 | * @return string[] |
| 207 | 198 | */ |
| 208 | - public function getConditions() | |
| 209 | - { | |
| 210 | - return $this->condition; | |
| 199 | + public function getConditions() { | |
| 200 | + return $this->_condition; | |
| 211 | 201 | } |
| 212 | 202 | |
| 213 | 203 | /** |
| 214 | 204 | * Set Conditions |
| 215 | 205 | * |
| 216 | - * @param string[] $pValue Condition | |
| 206 | + * @param string[] $pValue Condition | |
| 217 | 207 | * @return PHPExcel_Style_Conditional |
| 218 | 208 | */ |
| 219 | - public function setConditions($pValue) | |
| 220 | - { | |
| 221 | - if (!is_array($pValue)) { | |
| 222 | - $pValue = array($pValue); | |
| 223 | - } | |
| 224 | - $this->condition = $pValue; | |
| 225 | - return $this; | |
| 209 | + public function setConditions($pValue) { | |
| 210 | + if (!is_array($pValue)) | |
| 211 | + $pValue = array($pValue); | |
| 212 | + | |
| 213 | + $this->_condition = $pValue; | |
| 214 | + return $this; | |
| 226 | 215 | } |
| 227 | 216 | |
| 228 | 217 | /** |
| 229 | 218 | * Add Condition |
| 230 | 219 | * |
| 231 | - * @param string $pValue Condition | |
| 220 | + * @param string $pValue Condition | |
| 232 | 221 | * @return PHPExcel_Style_Conditional |
| 233 | 222 | */ |
| 234 | - public function addCondition($pValue = '') | |
| 235 | - { | |
| 236 | - $this->condition[] = $pValue; | |
| 237 | - return $this; | |
| 223 | + public function addCondition($pValue = '') { | |
| 224 | + $this->_condition[] = $pValue; | |
| 225 | + return $this; | |
| 238 | 226 | } |
| 239 | 227 | |
| 240 | 228 | /** |
| 241 | 229 | * Get Style |
| @@ -241,53 +229,49 @@ | ||
| 241 | 229 | * Get Style |
| 242 | 230 | * |
| 243 | 231 | * @return PHPExcel_Style |
| 244 | 232 | */ |
| 245 | - public function getStyle() | |
| 246 | - { | |
| 247 | - return $this->style; | |
| 233 | + public function getStyle() { | |
| 234 | + return $this->_style; | |
| 248 | 235 | } |
| 249 | 236 | |
| 250 | 237 | /** |
| 251 | 238 | * Set Style |
| 252 | 239 | * |
| 253 | - * @param PHPExcel_Style $pValue | |
| 254 | - * @throws PHPExcel_Exception | |
| 240 | + * @param PHPExcel_Style $pValue | |
| 241 | + * @throws PHPExcel_Exception | |
| 255 | 242 | * @return PHPExcel_Style_Conditional |
| 256 | 243 | */ |
| 257 | - public function setStyle(PHPExcel_Style $pValue = null) | |
| 258 | - { | |
| 259 | - $this->style = $pValue; | |
| 260 | - return $this; | |
| 244 | + public function setStyle(PHPExcel_Style $pValue = null) { | |
| 245 | + $this->_style = $pValue; | |
| 246 | + return $this; | |
| 261 | 247 | } |
| 262 | 248 | |
| 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 | - ); | |
| 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 | + ); | |
| 277 | 262 | } |
| 278 | 263 | |
| 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 | - } | |
| 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 | + } | |
| 293 | 277 | } |