ListParams.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Models\DTO\Movie;
  3. use JsonSerializable;
  4. class ListParams implements JsonSerializable
  5. {
  6. public string $key;
  7. public function __construct(
  8. public int|null $curPage = null,
  9. public int $itemPerPage = 10,
  10. public string|null $movieNm = "",
  11. public string|null $directorNm = null,
  12. public string|null $openStartDt = null,
  13. public string|null $openEndDt = null,
  14. public string|null $prdtStartYear = null,
  15. public string|null $prdtEndYear = null,
  16. public string|null $repNationCd = null,
  17. public string|null $movieTypeCd = null
  18. ) {
  19. $this->key = KOBIS_API_1;
  20. }
  21. public function jsonSerialize(): array
  22. {
  23. return [
  24. 'curPage' => $this->curPage,
  25. 'itemPerPage' => $this->itemPerPage,
  26. 'movieNm' => $this->movieNm,
  27. 'directorNm' => $this->directorNm,
  28. 'openStartDt' => $this->openStartDt,
  29. 'openEndDt' => $this->openEndDt,
  30. 'prdtStartYear' => $this->prdtStartYear,
  31. 'prdtEndYear' => $this->prdtEndYear,
  32. 'repNationCd' => $this->repNationCd,
  33. 'movieTypeCd' => $this->movieTypeCd
  34. ];
  35. }
  36. public function toArray(): array
  37. {
  38. return [
  39. 'key' => $this->key,
  40. 'curPage' => $this->curPage,
  41. 'itemPerPage' => $this->itemPerPage,
  42. 'movieNm' => $this->movieNm,
  43. 'directorNm' => $this->directorNm,
  44. 'openStartDt' => $this->openStartDt,
  45. 'openEndDt' => $this->openEndDt,
  46. 'prdtStartYear' => $this->prdtStartYear,
  47. 'prdtEndYear' => $this->prdtEndYear,
  48. 'repNationCd' => $this->repNationCd,
  49. 'movieTypeCd' => $this->movieTypeCd
  50. ];
  51. }
  52. public function toJson(): string|false
  53. {
  54. return json_encode([
  55. 'curPage' => $this->curPage,
  56. 'itemPerPage' => $this->itemPerPage,
  57. 'movieNm' => $this->movieNm,
  58. 'directorNm' => $this->directorNm,
  59. 'openStartDt' => $this->openStartDt,
  60. 'openEndDt' => $this->openEndDt,
  61. 'prdtStartYear' => $this->prdtStartYear,
  62. 'prdtEndYear' => $this->prdtEndYear,
  63. 'repNationCd' => $this->repNationCd,
  64. 'movieTypeCd' => $this->movieTypeCd
  65. ]);
  66. }
  67. }