Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
   4  
   5  use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
   6  use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column;
   7  
   8  class Rule
   9  {
  10      const AUTOFILTER_RULETYPE_FILTER = 'filter';
  11      const AUTOFILTER_RULETYPE_DATEGROUP = 'dateGroupItem';
  12      const AUTOFILTER_RULETYPE_CUSTOMFILTER = 'customFilter';
  13      const AUTOFILTER_RULETYPE_DYNAMICFILTER = 'dynamicFilter';
  14      const AUTOFILTER_RULETYPE_TOPTENFILTER = 'top10Filter';
  15  
  16      private static $ruleTypes = [
  17          //    Currently we're not handling
  18          //        colorFilter
  19          //        extLst
  20          //        iconFilter
  21          self::AUTOFILTER_RULETYPE_FILTER,
  22          self::AUTOFILTER_RULETYPE_DATEGROUP,
  23          self::AUTOFILTER_RULETYPE_CUSTOMFILTER,
  24          self::AUTOFILTER_RULETYPE_DYNAMICFILTER,
  25          self::AUTOFILTER_RULETYPE_TOPTENFILTER,
  26      ];
  27  
  28      const AUTOFILTER_RULETYPE_DATEGROUP_YEAR = 'year';
  29      const AUTOFILTER_RULETYPE_DATEGROUP_MONTH = 'month';
  30      const AUTOFILTER_RULETYPE_DATEGROUP_DAY = 'day';
  31      const AUTOFILTER_RULETYPE_DATEGROUP_HOUR = 'hour';
  32      const AUTOFILTER_RULETYPE_DATEGROUP_MINUTE = 'minute';
  33      const AUTOFILTER_RULETYPE_DATEGROUP_SECOND = 'second';
  34  
  35      private static $dateTimeGroups = [
  36          self::AUTOFILTER_RULETYPE_DATEGROUP_YEAR,
  37          self::AUTOFILTER_RULETYPE_DATEGROUP_MONTH,
  38          self::AUTOFILTER_RULETYPE_DATEGROUP_DAY,
  39          self::AUTOFILTER_RULETYPE_DATEGROUP_HOUR,
  40          self::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE,
  41          self::AUTOFILTER_RULETYPE_DATEGROUP_SECOND,
  42      ];
  43  
  44      const AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY = 'yesterday';
  45      const AUTOFILTER_RULETYPE_DYNAMIC_TODAY = 'today';
  46      const AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW = 'tomorrow';
  47      const AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE = 'yearToDate';
  48      const AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR = 'thisYear';
  49      const AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER = 'thisQuarter';
  50      const AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH = 'thisMonth';
  51      const AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK = 'thisWeek';
  52      const AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR = 'lastYear';
  53      const AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER = 'lastQuarter';
  54      const AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH = 'lastMonth';
  55      const AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK = 'lastWeek';
  56      const AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR = 'nextYear';
  57      const AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER = 'nextQuarter';
  58      const AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH = 'nextMonth';
  59      const AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK = 'nextWeek';
  60      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1 = 'M1';
  61      const AUTOFILTER_RULETYPE_DYNAMIC_JANUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1;
  62      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2 = 'M2';
  63      const AUTOFILTER_RULETYPE_DYNAMIC_FEBRUARY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2;
  64      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3 = 'M3';
  65      const AUTOFILTER_RULETYPE_DYNAMIC_MARCH = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3;
  66      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4 = 'M4';
  67      const AUTOFILTER_RULETYPE_DYNAMIC_APRIL = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4;
  68      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5 = 'M5';
  69      const AUTOFILTER_RULETYPE_DYNAMIC_MAY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5;
  70      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6 = 'M6';
  71      const AUTOFILTER_RULETYPE_DYNAMIC_JUNE = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6;
  72      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7 = 'M7';
  73      const AUTOFILTER_RULETYPE_DYNAMIC_JULY = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7;
  74      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8 = 'M8';
  75      const AUTOFILTER_RULETYPE_DYNAMIC_AUGUST = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8;
  76      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9 = 'M9';
  77      const AUTOFILTER_RULETYPE_DYNAMIC_SEPTEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9;
  78      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10 = 'M10';
  79      const AUTOFILTER_RULETYPE_DYNAMIC_OCTOBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10;
  80      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11 = 'M11';
  81      const AUTOFILTER_RULETYPE_DYNAMIC_NOVEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11;
  82      const AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12 = 'M12';
  83      const AUTOFILTER_RULETYPE_DYNAMIC_DECEMBER = self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12;
  84      const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_1 = 'Q1';
  85      const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_2 = 'Q2';
  86      const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_3 = 'Q3';
  87      const AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_4 = 'Q4';
  88      const AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE = 'aboveAverage';
  89      const AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE = 'belowAverage';
  90  
  91      private static $dynamicTypes = [
  92          self::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY,
  93          self::AUTOFILTER_RULETYPE_DYNAMIC_TODAY,
  94          self::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW,
  95          self::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE,
  96          self::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR,
  97          self::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER,
  98          self::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH,
  99          self::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK,
 100          self::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR,
 101          self::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER,
 102          self::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH,
 103          self::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK,
 104          self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR,
 105          self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER,
 106          self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH,
 107          self::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK,
 108          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_1,
 109          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_2,
 110          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_3,
 111          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_4,
 112          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_5,
 113          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_6,
 114          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_7,
 115          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_8,
 116          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_9,
 117          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_10,
 118          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_11,
 119          self::AUTOFILTER_RULETYPE_DYNAMIC_MONTH_12,
 120          self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_1,
 121          self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_2,
 122          self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_3,
 123          self::AUTOFILTER_RULETYPE_DYNAMIC_QUARTER_4,
 124          self::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE,
 125          self::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE,
 126      ];
 127  
 128      /*
 129       *    The only valid filter rule operators for filter and customFilter types are:
 130       *        <xsd:enumeration value="equal"/>
 131       *        <xsd:enumeration value="lessThan"/>
 132       *        <xsd:enumeration value="lessThanOrEqual"/>
 133       *        <xsd:enumeration value="notEqual"/>
 134       *        <xsd:enumeration value="greaterThanOrEqual"/>
 135       *        <xsd:enumeration value="greaterThan"/>
 136       */
 137      const AUTOFILTER_COLUMN_RULE_EQUAL = 'equal';
 138      const AUTOFILTER_COLUMN_RULE_NOTEQUAL = 'notEqual';
 139      const AUTOFILTER_COLUMN_RULE_GREATERTHAN = 'greaterThan';
 140      const AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL = 'greaterThanOrEqual';
 141      const AUTOFILTER_COLUMN_RULE_LESSTHAN = 'lessThan';
 142      const AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL = 'lessThanOrEqual';
 143  
 144      private static $operators = [
 145          self::AUTOFILTER_COLUMN_RULE_EQUAL,
 146          self::AUTOFILTER_COLUMN_RULE_NOTEQUAL,
 147          self::AUTOFILTER_COLUMN_RULE_GREATERTHAN,
 148          self::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL,
 149          self::AUTOFILTER_COLUMN_RULE_LESSTHAN,
 150          self::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL,
 151      ];
 152  
 153      const AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE = 'byValue';
 154      const AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT = 'byPercent';
 155  
 156      private static $topTenValue = [
 157          self::AUTOFILTER_COLUMN_RULE_TOPTEN_BY_VALUE,
 158          self::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT,
 159      ];
 160  
 161      const AUTOFILTER_COLUMN_RULE_TOPTEN_TOP = 'top';
 162      const AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM = 'bottom';
 163  
 164      private static $topTenType = [
 165          self::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP,
 166          self::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM,
 167      ];
 168  
 169      // Rule Operators (Numeric, Boolean etc)
 170  //    const AUTOFILTER_COLUMN_RULE_BETWEEN            = 'between';        //    greaterThanOrEqual 1 && lessThanOrEqual 2
 171      // Rule Operators (Numeric Special) which are translated to standard numeric operators with calculated values
 172  //    const AUTOFILTER_COLUMN_RULE_TOPTEN                = 'topTen';            //    greaterThan calculated value
 173  //    const AUTOFILTER_COLUMN_RULE_TOPTENPERCENT        = 'topTenPercent';    //    greaterThan calculated value
 174  //    const AUTOFILTER_COLUMN_RULE_ABOVEAVERAGE        = 'aboveAverage';    //    Value is calculated as the average
 175  //    const AUTOFILTER_COLUMN_RULE_BELOWAVERAGE        = 'belowAverage';    //    Value is calculated as the average
 176      // Rule Operators (String) which are set as wild-carded values
 177  //    const AUTOFILTER_COLUMN_RULE_BEGINSWITH            = 'beginsWith';            // A*
 178  //    const AUTOFILTER_COLUMN_RULE_ENDSWITH            = 'endsWith';            // *Z
 179  //    const AUTOFILTER_COLUMN_RULE_CONTAINS            = 'contains';            // *B*
 180  //    const AUTOFILTER_COLUMN_RULE_DOESNTCONTAIN        = 'notEqual';            //    notEqual *B*
 181      // Rule Operators (Date Special) which are translated to standard numeric operators with calculated values
 182  //    const AUTOFILTER_COLUMN_RULE_BEFORE                = 'lessThan';
 183  //    const AUTOFILTER_COLUMN_RULE_AFTER                = 'greaterThan';
 184  //    const AUTOFILTER_COLUMN_RULE_YESTERDAY            = 'yesterday';
 185  //    const AUTOFILTER_COLUMN_RULE_TODAY                = 'today';
 186  //    const AUTOFILTER_COLUMN_RULE_TOMORROW            = 'tomorrow';
 187  //    const AUTOFILTER_COLUMN_RULE_LASTWEEK            = 'lastWeek';
 188  //    const AUTOFILTER_COLUMN_RULE_THISWEEK            = 'thisWeek';
 189  //    const AUTOFILTER_COLUMN_RULE_NEXTWEEK            = 'nextWeek';
 190  //    const AUTOFILTER_COLUMN_RULE_LASTMONTH            = 'lastMonth';
 191  //    const AUTOFILTER_COLUMN_RULE_THISMONTH            = 'thisMonth';
 192  //    const AUTOFILTER_COLUMN_RULE_NEXTMONTH            = 'nextMonth';
 193  //    const AUTOFILTER_COLUMN_RULE_LASTQUARTER        = 'lastQuarter';
 194  //    const AUTOFILTER_COLUMN_RULE_THISQUARTER        = 'thisQuarter';
 195  //    const AUTOFILTER_COLUMN_RULE_NEXTQUARTER        = 'nextQuarter';
 196  //    const AUTOFILTER_COLUMN_RULE_LASTYEAR            = 'lastYear';
 197  //    const AUTOFILTER_COLUMN_RULE_THISYEAR            = 'thisYear';
 198  //    const AUTOFILTER_COLUMN_RULE_NEXTYEAR            = 'nextYear';
 199  //    const AUTOFILTER_COLUMN_RULE_YEARTODATE            = 'yearToDate';            //    <dynamicFilter val="40909" type="yearToDate" maxVal="41113"/>
 200  //    const AUTOFILTER_COLUMN_RULE_ALLDATESINMONTH    = 'allDatesInMonth';    //    <dynamicFilter type="M2"/> for Month/February
 201  //    const AUTOFILTER_COLUMN_RULE_ALLDATESINQUARTER    = 'allDatesInQuarter';    //    <dynamicFilter type="Q2"/> for Quarter 2
 202  
 203      /**
 204       * Autofilter Column.
 205       *
 206       * @var Column
 207       */
 208      private $parent;
 209  
 210      /**
 211       * Autofilter Rule Type.
 212       *
 213       * @var string
 214       */
 215      private $ruleType = self::AUTOFILTER_RULETYPE_FILTER;
 216  
 217      /**
 218       * Autofilter Rule Value.
 219       *
 220       * @var string
 221       */
 222      private $value = '';
 223  
 224      /**
 225       * Autofilter Rule Operator.
 226       *
 227       * @var string
 228       */
 229      private $operator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
 230  
 231      /**
 232       * DateTimeGrouping Group Value.
 233       *
 234       * @var string
 235       */
 236      private $grouping = '';
 237  
 238      /**
 239       * Create a new Rule.
 240       *
 241       * @param Column $pParent
 242       */
 243      public function __construct(?Column $pParent = null)
 244      {
 245          $this->parent = $pParent;
 246      }
 247  
 248      /**
 249       * Get AutoFilter Rule Type.
 250       *
 251       * @return string
 252       */
 253      public function getRuleType()
 254      {
 255          return $this->ruleType;
 256      }
 257  
 258      /**
 259       * Set AutoFilter Rule Type.
 260       *
 261       * @param string $pRuleType see self::AUTOFILTER_RULETYPE_*
 262       *
 263       * @return $this
 264       */
 265      public function setRuleType($pRuleType)
 266      {
 267          if (!in_array($pRuleType, self::$ruleTypes)) {
 268              throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.');
 269          }
 270  
 271          $this->ruleType = $pRuleType;
 272  
 273          return $this;
 274      }
 275  
 276      /**
 277       * Get AutoFilter Rule Value.
 278       *
 279       * @return string
 280       */
 281      public function getValue()
 282      {
 283          return $this->value;
 284      }
 285  
 286      /**
 287       * Set AutoFilter Rule Value.
 288       *
 289       * @param string|string[] $pValue
 290       *
 291       * @return $this
 292       */
 293      public function setValue($pValue)
 294      {
 295          if (is_array($pValue)) {
 296              $grouping = -1;
 297              foreach ($pValue as $key => $value) {
 298                  //    Validate array entries
 299                  if (!in_array($key, self::$dateTimeGroups)) {
 300                      //    Remove any invalid entries from the value array
 301                      unset($pValue[$key]);
 302                  } else {
 303                      //    Work out what the dateTime grouping will be
 304                      $grouping = max($grouping, array_search($key, self::$dateTimeGroups));
 305                  }
 306              }
 307              if (count($pValue) == 0) {
 308                  throw new PhpSpreadsheetException('Invalid rule value for column AutoFilter Rule.');
 309              }
 310              //    Set the dateTime grouping that we've anticipated
 311              $this->setGrouping(self::$dateTimeGroups[$grouping]);
 312          }
 313          $this->value = $pValue;
 314  
 315          return $this;
 316      }
 317  
 318      /**
 319       * Get AutoFilter Rule Operator.
 320       *
 321       * @return string
 322       */
 323      public function getOperator()
 324      {
 325          return $this->operator;
 326      }
 327  
 328      /**
 329       * Set AutoFilter Rule Operator.
 330       *
 331       * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_*
 332       *
 333       * @return $this
 334       */
 335      public function setOperator($pOperator)
 336      {
 337          if (empty($pOperator)) {
 338              $pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
 339          }
 340          if (
 341              (!in_array($pOperator, self::$operators)) &&
 342              (!in_array($pOperator, self::$topTenValue))
 343          ) {
 344              throw new PhpSpreadsheetException('Invalid operator for column AutoFilter Rule.');
 345          }
 346          $this->operator = $pOperator;
 347  
 348          return $this;
 349      }
 350  
 351      /**
 352       * Get AutoFilter Rule Grouping.
 353       *
 354       * @return string
 355       */
 356      public function getGrouping()
 357      {
 358          return $this->grouping;
 359      }
 360  
 361      /**
 362       * Set AutoFilter Rule Grouping.
 363       *
 364       * @param string $pGrouping
 365       *
 366       * @return $this
 367       */
 368      public function setGrouping($pGrouping)
 369      {
 370          if (
 371              ($pGrouping !== null) &&
 372              (!in_array($pGrouping, self::$dateTimeGroups)) &&
 373              (!in_array($pGrouping, self::$dynamicTypes)) &&
 374              (!in_array($pGrouping, self::$topTenType))
 375          ) {
 376              throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.');
 377          }
 378          $this->grouping = $pGrouping;
 379  
 380          return $this;
 381      }
 382  
 383      /**
 384       * Set AutoFilter Rule.
 385       *
 386       * @param string $pOperator see self::AUTOFILTER_COLUMN_RULE_*
 387       * @param string|string[] $pValue
 388       * @param string $pGrouping
 389       *
 390       * @return $this
 391       */
 392      public function setRule($pOperator, $pValue, $pGrouping = null)
 393      {
 394          $this->setOperator($pOperator);
 395          $this->setValue($pValue);
 396          //  Only set grouping if it's been passed in as a user-supplied argument,
 397          //      otherwise we're calculating it when we setValue() and don't want to overwrite that
 398          //      If the user supplies an argumnet for grouping, then on their own head be it
 399          if ($pGrouping !== null) {
 400              $this->setGrouping($pGrouping);
 401          }
 402  
 403          return $this;
 404      }
 405  
 406      /**
 407       * Get this Rule's AutoFilter Column Parent.
 408       *
 409       * @return Column
 410       */
 411      public function getParent()
 412      {
 413          return $this->parent;
 414      }
 415  
 416      /**
 417       * Set this Rule's AutoFilter Column Parent.
 418       *
 419       * @param Column $pParent
 420       *
 421       * @return $this
 422       */
 423      public function setParent(?Column $pParent = null)
 424      {
 425          $this->parent = $pParent;
 426  
 427          return $this;
 428      }
 429  
 430      /**
 431       * Implement PHP __clone to create a deep clone, not just a shallow copy.
 432       */
 433      public function __clone()
 434      {
 435          $vars = get_object_vars($this);
 436          foreach ($vars as $key => $value) {
 437              if (is_object($value)) {
 438                  if ($key == 'parent') {
 439                      //    Detach from autofilter column parent
 440                      $this->$key = null;
 441                  } else {
 442                      $this->$key = clone $value;
 443                  }
 444              } else {
 445                  $this->$key = $value;
 446              }
 447          }
 448      }
 449  }