InfoParams.php 984 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Models\DTO\Movie;
  3. use JsonSerializable;
  4. class InfoParams implements JsonSerializable
  5. {
  6. public string $key;
  7. public function __construct(
  8. public string $movieCd = "",
  9. public int $dailyID = 0,
  10. public int $weeklyID = 0
  11. ) {
  12. $this->key = KOBIS_API_1;
  13. }
  14. public function jsonSerialize(): array
  15. {
  16. return [
  17. 'movieCd' => $this->movieCd,
  18. 'dailyID' => $this->dailyID,
  19. 'weeklyID' => $this->weeklyID
  20. ];
  21. }
  22. public function toArray(): array
  23. {
  24. return [
  25. 'key' => $this->key,
  26. 'movieCd' => $this->movieCd,
  27. 'dailyID' => $this->dailyID,
  28. 'weeklyID' => $this->weeklyID
  29. ];
  30. }
  31. public function toJson(): string|false
  32. {
  33. return json_encode([
  34. 'movieCd' => $this->movieCd,
  35. 'dailyID' => $this->dailyID,
  36. 'weeklyID' => $this->weeklyID
  37. ]);
  38. }
  39. }