PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/branches/v1.4.0/Classes/PHPExcel/Style/Conditional.php

#
PHP | 203 lines | 73 code | 21 blank | 109 comment | 2 complexity | e106f8d76cb45cb198f8be288cfd67c3 MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.0, LGPL-2.1, GPL-3.0, LGPL-3.0
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2007 PHPExcel
  6. *
  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.
  11. *
  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.
  16. *
  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
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Style
  23. * @copyright Copyright (c) 2006 - 2007 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/lgpl.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. /** PHPExcel_Style */
  28. require_once 'PHPExcel/Style.php';
  29. /** PHPExcel_IComparable */
  30. require_once 'PHPExcel/IComparable.php';
  31. /**
  32. * PHPExcel_Style_Conditional
  33. *
  34. * @category PHPExcel
  35. * @package PHPExcel_Style
  36. * @copyright Copyright (c) 2006 - 2007 PHPExcel (http://www.codeplex.com/PHPExcel)
  37. */
  38. class PHPExcel_Style_Conditional implements PHPExcel_IComparable
  39. {
  40. /* Condition types */
  41. const CONDITION_NONE = 'none';
  42. const CONDITION_CELLIS = 'cellIs';
  43. /* Operator types */
  44. const OPERATOR_NONE = '';
  45. const OPERATOR_BEGINSWITH = 'beginsWith';
  46. const OPERATOR_ENDSWITH = 'endsWith';
  47. const OPERATOR_EQUAL = 'equal';
  48. const OPERATOR_GREATERTHAN = 'greaterThan';
  49. const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
  50. const OPERATOR_LESSTHAN = 'lessThan';
  51. const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
  52. const OPERATOR_NOTEQUAL = 'notEqual';
  53. const OPERATOR_CONTAINSTEXT = 'containsText';
  54. const OPERATOR_NOTCONTAINS = 'notContains';
  55. /**
  56. * Condition type
  57. *
  58. * @var int
  59. */
  60. private $_conditionType;
  61. /**
  62. * Operator type
  63. *
  64. * @var int
  65. */
  66. private $_operatorType;
  67. /**
  68. * Condition
  69. *
  70. * @var string
  71. */
  72. private $_condition;
  73. /**
  74. * Style
  75. *
  76. * @var PHPExcel_Style
  77. */
  78. private $_style;
  79. /**
  80. * Create a new PHPExcel_Style_Conditional
  81. */
  82. public function __construct()
  83. {
  84. // Initialise values
  85. $this->_conditionType = PHPExcel_Style_Conditional::CONDITION_NONE;
  86. $this->_operatorType = PHPExcel_Style_Conditional::OPERATOR_NONE;
  87. $this->_condition = '';
  88. $this->_style = new PHPExcel_Style();
  89. }
  90. /**
  91. * Get Condition type
  92. *
  93. * @return string
  94. */
  95. public function getConditionType() {
  96. return $this->_conditionType;
  97. }
  98. /**
  99. * Set Condition type
  100. *
  101. * @param string $pValue PHPExcel_Style_Conditional condition type
  102. */
  103. public function setConditionType($pValue = PHPExcel_Style_Conditional::CONDITION_NONE) {
  104. $this->_conditionType = $pValue;
  105. }
  106. /**
  107. * Get Operator type
  108. *
  109. * @return string
  110. */
  111. public function getOperatorType() {
  112. return $this->_operatorType;
  113. }
  114. /**
  115. * Set Operator type
  116. *
  117. * @param string $pValue PHPExcel_Style_Conditional operator type
  118. */
  119. public function setOperatorType($pValue = PHPExcel_Style_Conditional::OPERATOR_NONE) {
  120. $this->_operatorType = $pValue;
  121. }
  122. /**
  123. * Get Condition
  124. *
  125. * @return string
  126. */
  127. public function getCondition() {
  128. return $this->_condition;
  129. }
  130. /**
  131. * Set Condition
  132. *
  133. * @param string $pValue Condition
  134. */
  135. public function setCondition($pValue = '') {
  136. $this->_condition = $pValue;
  137. }
  138. /**
  139. * Get Style
  140. *
  141. * @return PHPExcel_Style
  142. */
  143. public function getStyle() {
  144. return $this->_style;
  145. }
  146. /**
  147. * Set Style
  148. *
  149. * @param PHPExcel_Style $pValue
  150. * @throws Exception
  151. */
  152. public function setStyle(PHPExcel_Style $pValue = null) {
  153. $this->_style = $pValue;
  154. }
  155. /**
  156. * Get hash code
  157. *
  158. * @return string Hash code
  159. */
  160. public function getHashCode() {
  161. return md5(
  162. $this->_conditionType
  163. . $this->_operatorType
  164. . $this->_condition
  165. . $this->_style->getHashCode()
  166. . __CLASS__
  167. );
  168. }
  169. /**
  170. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  171. */
  172. public function __clone() {
  173. $vars = get_object_vars($this);
  174. foreach ($vars as $key => $value) {
  175. if (is_object($value)) {
  176. $this->$key = clone $value;
  177. } else {
  178. $this->$key = $value;
  179. }
  180. }
  181. }
  182. }