Article.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace internship\bo;
  3. use n2n\reflection\ObjectAdapter;
  4. use n2n\util\type\ArgUtils;
  5. enum CategoryName: string {
  6. case sport = 'sport';
  7. case national ='national';
  8. case international = 'international';
  9. }
  10. class Article extends ObjectAdapter implements \JsonSerializable {
  11. private int $id;
  12. private CategoryName $categoryName;
  13. private string $text;
  14. private string $title;
  15. /**
  16. * @return int
  17. */
  18. public function getId(): int {
  19. return $this->id;
  20. }
  21. /**
  22. * @param int $id
  23. */
  24. public function setId(int $id): void {
  25. $this->id = $id;
  26. }
  27. /**
  28. * @return CategoryName
  29. */
  30. public function getCategoryName(): CategoryName {
  31. return $this->categoryName;
  32. }
  33. /**
  34. * @param CategoryName $categoryName
  35. */
  36. public function setCategoryName(CategoryName $categoryName): void {
  37. //ArgUtils::valEnum($categoryName, CategoryName::cases());
  38. $this->categoryName = $categoryName;
  39. }
  40. /**
  41. * @return string
  42. */
  43. public function getText(): string {
  44. return $this->text;
  45. }
  46. /**
  47. * @param string $text
  48. */
  49. public function setText(string $text): void {
  50. $this->text = $text;
  51. }
  52. /**
  53. * @return string
  54. */
  55. public function getTitle(): string {
  56. return $this->title;
  57. }
  58. /**
  59. * @param string $title
  60. */
  61. public function setTitle(string $title): void {
  62. $this->title = $title;
  63. }
  64. function jsonSerialize(): mixed {
  65. return [
  66. 'id' => $this->id,
  67. 'title' => $this->title,
  68. 'categoryName' => $this->categoryName,
  69. 'text' => $this->text
  70. ];
  71. }
  72. }