2
0

CommentTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Test\PhpDevCommunity\PaperORM\Entity;
  3. use PhpDevCommunity\PaperORM\Entity\EntityInterface;
  4. use PhpDevCommunity\PaperORM\Mapping\Column\StringColumn;
  5. use PhpDevCommunity\PaperORM\Mapping\Column\JoinColumn;
  6. use PhpDevCommunity\PaperORM\Mapping\Column\PrimaryKeyColumn;
  7. use Test\PhpDevCommunity\PaperORM\Repository\TagTestRepository;
  8. class CommentTest implements EntityInterface
  9. {
  10. private ?int $id = null;
  11. private ?string $body = null;
  12. private ?PostTest $post = null;
  13. static public function getTableName(): string
  14. {
  15. return 'comment';
  16. }
  17. static public function getRepositoryName(): ?string
  18. {
  19. return null;
  20. }
  21. static public function columnsMapping(): array
  22. {
  23. return [
  24. new PrimaryKeyColumn('id'),
  25. new StringColumn('body'),
  26. new JoinColumn('post', 'post_id', 'id', PostTest::class),
  27. ];
  28. }
  29. public function getPrimaryKeyValue() : ?int
  30. {
  31. return $this->getId();
  32. }
  33. public function getId(): ?int
  34. {
  35. return $this->id;
  36. }
  37. public function getBody(): ?string
  38. {
  39. return $this->body;
  40. }
  41. public function setBody(?string $body): CommentTest
  42. {
  43. $this->body = $body;
  44. return $this;
  45. }
  46. public function getPost(): ?PostTest
  47. {
  48. return $this->post;
  49. }
  50. public function setPost(?PostTest $post): CommentTest
  51. {
  52. $this->post = $post;
  53. return $this;
  54. }
  55. }