2
0

CommentTest.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\Column\UuidColumn;
  9. use PhpDevCommunity\PaperORM\Mapping\Entity;
  10. use Test\PhpDevCommunity\PaperORM\Repository\TagTestRepository;
  11. #[Entity(table : 'comment', repository : null)]
  12. class CommentTest implements EntityInterface, TableMetadataInterface
  13. {
  14. private ?int $id = null;
  15. private ?string $body = null;
  16. private ?string $uuid = null;
  17. private ?PostTest $post = null;
  18. static public function getTableName(): string
  19. {
  20. return 'comment';
  21. }
  22. static public function getRepositoryName(): ?string
  23. {
  24. return null;
  25. }
  26. static public function columnsMapping(): array
  27. {
  28. return [
  29. (new PrimaryKeyColumn())->bindProperty('id'),
  30. (new StringColumn())->bindProperty('body'),
  31. (new UuidColumn())->bindProperty('uuid'),
  32. (new JoinColumn('post_id', PostTest::class))->bindProperty('post'),
  33. ];
  34. }
  35. public function getPrimaryKeyValue() : ?int
  36. {
  37. return $this->getId();
  38. }
  39. public function getId(): ?int
  40. {
  41. return $this->id;
  42. }
  43. public function getBody(): ?string
  44. {
  45. return $this->body;
  46. }
  47. public function setBody(?string $body): CommentTest
  48. {
  49. $this->body = $body;
  50. return $this;
  51. }
  52. public function getUuid(): ?string
  53. {
  54. return $this->uuid;
  55. }
  56. public function setUuid(?string $uuid): CommentTest
  57. {
  58. $this->uuid = $uuid;
  59. return $this;
  60. }
  61. public function getPost(): ?PostTest
  62. {
  63. return $this->post;
  64. }
  65. public function setPost(?PostTest $post): CommentTest
  66. {
  67. $this->post = $post;
  68. return $this;
  69. }
  70. }