tablepress
/
libraries
/
vendor
/
PhpSpreadsheet
/
Style
/
ConditionalFormatting
/
ConditionalDataBarExtension.php
ConditionalDataBarExtension.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php
| 1 | <?php |
| 2 | |
| 3 | namespace TablePress\PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting; |
| 4 | |
| 5 | class ConditionalDataBarExtension |
| 6 | { |
| 7 | /** <dataBar> attributes */ |
| 8 | private int $minLength; |
| 9 | |
| 10 | private int $maxLength; |
| 11 | |
| 12 | private ?bool $border = null; |
| 13 | |
| 14 | private ?bool $gradient = null; |
| 15 | |
| 16 | private ?string $direction = null; |
| 17 | |
| 18 | private ?bool $negativeBarBorderColorSameAsPositive = null; |
| 19 | |
| 20 | private ?string $axisPosition = null; |
| 21 | |
| 22 | // <dataBar> children |
| 23 | |
| 24 | private ConditionalFormatValueObject $maximumConditionalFormatValueObject; |
| 25 | |
| 26 | private ConditionalFormatValueObject $minimumConditionalFormatValueObject; |
| 27 | |
| 28 | private ?string $borderColor = null; |
| 29 | |
| 30 | private ?string $negativeFillColor = null; |
| 31 | |
| 32 | private ?string $negativeBorderColor = null; |
| 33 | |
| 34 | /** @var array{rgb: ?string, theme: ?string, tint: ?string} */ |
| 35 | private array $axisColor = [ |
| 36 | 'rgb' => null, |
| 37 | 'theme' => null, |
| 38 | 'tint' => null, |
| 39 | ]; |
| 40 | |
| 41 | /** @return mixed[] */ |
| 42 | public function getXmlAttributes(): array |
| 43 | { |
| 44 | $ret = []; |
| 45 | foreach (['minLength', 'maxLength', 'direction', 'axisPosition'] as $attrKey) { |
| 46 | if (null !== $this->{$attrKey}) { |
| 47 | $ret[$attrKey] = $this->{$attrKey}; |
| 48 | } |
| 49 | } |
| 50 | foreach (['border', 'gradient', 'negativeBarBorderColorSameAsPositive'] as $attrKey) { |
| 51 | if (null !== $this->{$attrKey}) { |
| 52 | $ret[$attrKey] = $this->{$attrKey} ? '1' : '0'; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | return $ret; |
| 57 | } |
| 58 | |
| 59 | /** @return mixed[] */ |
| 60 | public function getXmlElements(): array |
| 61 | { |
| 62 | $ret = []; |
| 63 | $elms = ['borderColor', 'negativeFillColor', 'negativeBorderColor']; |
| 64 | foreach ($elms as $elmKey) { |
| 65 | if (null !== $this->{$elmKey}) { |
| 66 | $ret[$elmKey] = ['rgb' => $this->{$elmKey}]; |
| 67 | } |
| 68 | } |
| 69 | foreach (array_filter($this->axisColor) as $attrKey => $axisColorAttr) { |
| 70 | if (!isset($ret['axisColor'])) { |
| 71 | $ret['axisColor'] = []; |
| 72 | } |
| 73 | $ret['axisColor'][$attrKey] = $axisColorAttr; |
| 74 | } |
| 75 | |
| 76 | return $ret; |
| 77 | } |
| 78 | |
| 79 | public function getMinLength(): int |
| 80 | { |
| 81 | return $this->minLength; |
| 82 | } |
| 83 | |
| 84 | public function setMinLength(int $minLength): self |
| 85 | { |
| 86 | $this->minLength = $minLength; |
| 87 | |
| 88 | return $this; |
| 89 | } |
| 90 | |
| 91 | public function getMaxLength(): int |
| 92 | { |
| 93 | return $this->maxLength; |
| 94 | } |
| 95 | |
| 96 | public function setMaxLength(int $maxLength): self |
| 97 | { |
| 98 | $this->maxLength = $maxLength; |
| 99 | |
| 100 | return $this; |
| 101 | } |
| 102 | |
| 103 | public function getBorder(): ?bool |
| 104 | { |
| 105 | return $this->border; |
| 106 | } |
| 107 | |
| 108 | public function setBorder(bool $border): self |
| 109 | { |
| 110 | $this->border = $border; |
| 111 | |
| 112 | return $this; |
| 113 | } |
| 114 | |
| 115 | public function getGradient(): ?bool |
| 116 | { |
| 117 | return $this->gradient; |
| 118 | } |
| 119 | |
| 120 | public function setGradient(bool $gradient): self |
| 121 | { |
| 122 | $this->gradient = $gradient; |
| 123 | |
| 124 | return $this; |
| 125 | } |
| 126 | |
| 127 | public function getDirection(): ?string |
| 128 | { |
| 129 | return $this->direction; |
| 130 | } |
| 131 | |
| 132 | public function setDirection(string $direction): self |
| 133 | { |
| 134 | $this->direction = $direction; |
| 135 | |
| 136 | return $this; |
| 137 | } |
| 138 | |
| 139 | public function getNegativeBarBorderColorSameAsPositive(): ?bool |
| 140 | { |
| 141 | return $this->negativeBarBorderColorSameAsPositive; |
| 142 | } |
| 143 | |
| 144 | public function setNegativeBarBorderColorSameAsPositive(bool $negativeBarBorderColorSameAsPositive): self |
| 145 | { |
| 146 | $this->negativeBarBorderColorSameAsPositive = $negativeBarBorderColorSameAsPositive; |
| 147 | |
| 148 | return $this; |
| 149 | } |
| 150 | |
| 151 | public function getAxisPosition(): ?string |
| 152 | { |
| 153 | return $this->axisPosition; |
| 154 | } |
| 155 | |
| 156 | public function setAxisPosition(string $axisPosition): self |
| 157 | { |
| 158 | $this->axisPosition = $axisPosition; |
| 159 | |
| 160 | return $this; |
| 161 | } |
| 162 | |
| 163 | public function getMaximumConditionalFormatValueObject(): ConditionalFormatValueObject |
| 164 | { |
| 165 | return $this->maximumConditionalFormatValueObject; |
| 166 | } |
| 167 | |
| 168 | public function setMaximumConditionalFormatValueObject(ConditionalFormatValueObject $maximumConditionalFormatValueObject): self |
| 169 | { |
| 170 | $this->maximumConditionalFormatValueObject = $maximumConditionalFormatValueObject; |
| 171 | |
| 172 | return $this; |
| 173 | } |
| 174 | |
| 175 | public function getMinimumConditionalFormatValueObject(): ConditionalFormatValueObject |
| 176 | { |
| 177 | return $this->minimumConditionalFormatValueObject; |
| 178 | } |
| 179 | |
| 180 | public function setMinimumConditionalFormatValueObject(ConditionalFormatValueObject $minimumConditionalFormatValueObject): self |
| 181 | { |
| 182 | $this->minimumConditionalFormatValueObject = $minimumConditionalFormatValueObject; |
| 183 | |
| 184 | return $this; |
| 185 | } |
| 186 | |
| 187 | public function getBorderColor(): ?string |
| 188 | { |
| 189 | return $this->borderColor; |
| 190 | } |
| 191 | |
| 192 | public function setBorderColor(string $borderColor): self |
| 193 | { |
| 194 | $this->borderColor = $borderColor; |
| 195 | |
| 196 | return $this; |
| 197 | } |
| 198 | |
| 199 | public function getNegativeFillColor(): ?string |
| 200 | { |
| 201 | return $this->negativeFillColor; |
| 202 | } |
| 203 | |
| 204 | public function setNegativeFillColor(string $negativeFillColor): self |
| 205 | { |
| 206 | $this->negativeFillColor = $negativeFillColor; |
| 207 | |
| 208 | return $this; |
| 209 | } |
| 210 | |
| 211 | public function getNegativeBorderColor(): ?string |
| 212 | { |
| 213 | return $this->negativeBorderColor; |
| 214 | } |
| 215 | |
| 216 | public function setNegativeBorderColor(string $negativeBorderColor): self |
| 217 | { |
| 218 | $this->negativeBorderColor = $negativeBorderColor; |
| 219 | |
| 220 | return $this; |
| 221 | } |
| 222 | |
| 223 | /** @return array{rgb: ?string, theme: ?string, tint: ?string} */ |
| 224 | public function getAxisColor(): array |
| 225 | { |
| 226 | return $this->axisColor; |
| 227 | } |
| 228 | |
| 229 | public function setAxisColor(?string $rgb, ?string $theme = null, ?string $tint = null): self |
| 230 | { |
| 231 | $this->axisColor = [ |
| 232 | 'rgb' => $rgb, |
| 233 | 'theme' => $theme, |
| 234 | 'tint' => $tint, |
| 235 | ]; |
| 236 | |
| 237 | return $this; |
| 238 | } |
| 239 | } |
| 240 |