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

/application/third_party/phpoffice/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php

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