123456789101112131415161718192021222324252627 |
- <?php
- namespace DNB;
- class Customer extends AbstractPostSerializable implements PostSerializableInterface {
- public function __construct(
- private string $name,
- private ?string $email,
- private string $mobilePhone,
- private ?string $zipCode = null,
- private ?string $comment = null,
- ) {}
- public function toPostParams(): array {
- $arr = [];
- foreach (static::getClassVars() as $key)
- if (!is_null($this->{$key}))
- $arr[$key] = $this->{$key};
- return $arr;
- }
- protected static function getClassVars(): array {
- return array_keys(get_class_vars(__CLASS__));
- }
- }
|