2
0

PaperKeyValue.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace PhpDevCommunity\PaperORM\Internal\Entity;
  3. use PhpDevCommunity\PaperORM\Entity\EntityInterface;
  4. use PhpDevCommunity\PaperORM\Entity\SystemEntityInterface;
  5. use PhpDevCommunity\PaperORM\Mapping\Column\AnyColumn;
  6. use PhpDevCommunity\PaperORM\Mapping\Column\PrimaryKeyColumn;
  7. use PhpDevCommunity\PaperORM\Mapping\Column\StringColumn;
  8. use PhpDevCommunity\PaperORM\Mapping\Column\TimestampColumn;
  9. use PhpDevCommunity\PaperORM\Mapping\Entity;
  10. #[Entity(table : 'paper_key_value')]
  11. class PaperKeyValue implements EntityInterface, SystemEntityInterface
  12. {
  13. #[PrimaryKeyColumn]
  14. private ?int $id = null;
  15. #[StringColumn(name: 'k', length: 100, nullable: false, unique: true)]
  16. private ?string $key = null;
  17. /**
  18. * @var mixed
  19. */
  20. #[AnyColumn(name: 'val')]
  21. private $value = null;
  22. #[TimestampColumn(name: 'created_at', onCreated: true)]
  23. private ?\DateTimeInterface $createdAt = null;
  24. #[TimestampColumn(name: 'updated_at', onCreated: false, onUpdated: true)]
  25. private ?\DateTimeInterface $updatedAt = null;
  26. public function getPrimaryKeyValue() : ?int
  27. {
  28. return $this->id;
  29. }
  30. public function getKey(): ?string
  31. {
  32. return $this->key;
  33. }
  34. public function setKey(?string $key): PaperKeyValue
  35. {
  36. $this->key = $key;
  37. return $this;
  38. }
  39. public function getValue()
  40. {
  41. return $this->value;
  42. }
  43. public function setValue($value): PaperKeyValue
  44. {
  45. $this->value = $value;
  46. return $this;
  47. }
  48. public function getCreatedAt(): ?\DateTimeInterface
  49. {
  50. return $this->createdAt;
  51. }
  52. public function setCreatedAt(?\DateTimeInterface $createdAt): PaperKeyValue
  53. {
  54. $this->createdAt = $createdAt;
  55. return $this;
  56. }
  57. public function getUpdatedAt(): ?\DateTimeInterface
  58. {
  59. return $this->updatedAt;
  60. }
  61. public function setUpdatedAt(?\DateTimeInterface $updatedAt): PaperKeyValue
  62. {
  63. $this->updatedAt = $updatedAt;
  64. return $this;
  65. }
  66. static public function getTableName(): string
  67. {
  68. return 'paper_key_value';
  69. }
  70. static public function getRepositoryName(): ?string
  71. {
  72. return null;
  73. }
  74. static public function columnsMapping(): array
  75. {
  76. return [
  77. (new PrimaryKeyColumn())->bindProperty('id'),
  78. (new StringColumn('k', 100, false, null, true))->bindProperty('key'),
  79. (new AnyColumn('val'))->bindProperty('value'),
  80. (new TimestampColumn('created_at', true))->bindProperty('createdAt'),
  81. (new TimestampColumn('updated_at', false, true))->bindProperty('updatedAt'),
  82. ];
  83. }
  84. }