AuthData.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Models\DTO\Toss;
  3. use Illuminate\Contracts\Support\Arrayable;
  4. class AuthData implements Arrayable
  5. {
  6. public string $requestType;
  7. public ?string $triggerType;
  8. public ?string $userName;
  9. public ?string $userPhone;
  10. public ?string $userBirthday;
  11. public ?string $sessionKey;
  12. public ?string $successCallbackUrl;
  13. public ?string $failCallbackUrl;
  14. public ?string $nonce;
  15. public ?int $expireSeconds;
  16. public function __construct(
  17. string $requestType, ?string $triggerType = null,
  18. ?string $userName = null, ?string $userPhone = null, ?string $userBirthday = null,
  19. ?string $sessionKey = null, ?string $successCallbackUrl = null, ?string $failCallbackUrl = null,
  20. ?string $nonce = null, ?int $expireSeconds = null,
  21. ) {
  22. $this->requestType = $requestType;
  23. $this->triggerType = $triggerType;
  24. $this->userName = $userName;
  25. $this->userPhone = $userPhone;
  26. $this->userBirthday = $userBirthday;
  27. $this->sessionKey = $sessionKey;
  28. $this->successCallbackUrl = $successCallbackUrl;
  29. $this->failCallbackUrl = $failCallbackUrl;
  30. $this->nonce = $nonce;
  31. $this->expireSeconds = $expireSeconds;
  32. }
  33. public function __set($name, $value)
  34. {
  35. $this->{$name} = $value;
  36. }
  37. public function __get($name): mixed
  38. {
  39. return ($this->{$name} ?? null);
  40. }
  41. public function toArray(): array
  42. {
  43. return array_filter(call_user_func('get_object_vars', $this));
  44. }
  45. }