Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

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