Customer.php 872 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace DNB;
  3. class Customer extends AbstractPostSerializable implements PostSerializableInterface {
  4. private string $name;
  5. private ?string $email;
  6. private string $mobilePhone;
  7. private ?string $zipCode;
  8. private ?string $comment;
  9. public function __construct(
  10. string $name,
  11. string $mobilePhone,
  12. ?string $email = null,
  13. ?string $zipCode = null,
  14. ?string $comment = null
  15. ) {
  16. $this->name = $name;
  17. $this->email = $email;
  18. $this->mobilePhone = $mobilePhone;
  19. $this->zipCode = $zipCode;
  20. $this->comment = $comment;
  21. }
  22. public function toPostParams(): array {
  23. $arr = [];
  24. foreach (array_keys(static::getPostParams(true)) as $key)
  25. if (!is_null($this->{$key}))
  26. $arr[$key] = $this->{$key};
  27. return $arr;
  28. }
  29. }