Questionaire.php 984 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace DNB;
  3. class Questionaire extends AbstractPostSerializable implements PostSerializableInterface {
  4. private ?bool $keepMeInformedOnBids;
  5. private ?bool $contactForPropertyValuation;
  6. private ?bool $contactForEconomicalAdvice;
  7. public function __construct(
  8. ?bool $keepMeInformedOnBids = null,
  9. ?bool $contactForPropertyValuation = null,
  10. ?bool $contactForEconomicalAdvice = null
  11. ){
  12. $this->keepMeInformedOnBids = $keepMeInformedOnBids;
  13. $this->contactForPropertyValuation = $contactForPropertyValuation;
  14. $this->contactForEconomicalAdvice = $contactForEconomicalAdvice;
  15. }
  16. public function toPostParams(): array {
  17. $arr = [];
  18. foreach (static::getClassVars() as $key)
  19. $arr[$key] = !is_null($this->{$key}) ? $this->{$key} : false;
  20. return $arr;
  21. }
  22. protected static function getClassVars(): array {
  23. return array_keys(get_class_vars(__CLASS__));
  24. }
  25. }