2
0

CommentTest.php 1.7 KB

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