説明なし

SubscriberIPEntity.php 979B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace MailPoet\Entities;
  3. if (!defined('ABSPATH')) exit;
  4. use DateTimeInterface;
  5. use MailPoetVendor\Carbon\Carbon;
  6. use MailPoetVendor\Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity()
  9. * @ORM\Table(name="subscriber_ips")
  10. */
  11. class SubscriberIPEntity {
  12. /**
  13. * @ORM\Id
  14. * @ORM\Column(type="string")
  15. * @var string
  16. */
  17. private $ip;
  18. /**
  19. * We have to use own type because createdAt is part of the primary key and basic datetimetz isn't supported in primary key
  20. * @ORM\Id
  21. * @ORM\Column(type="datetimetz_to_string")
  22. * @var DateTimeInterface
  23. */
  24. private $createdAt;
  25. public function __construct(
  26. string $ip
  27. ) {
  28. $this->ip = $ip;
  29. $this->createdAt = new Carbon();
  30. }
  31. public function getIP(): string {
  32. return $this->ip;
  33. }
  34. public function getCreatedAt(): DateTimeInterface {
  35. return $this->createdAt;
  36. }
  37. public function setCreatedAt(DateTimeInterface $createdAt): void {
  38. $this->createdAt = $createdAt;
  39. }
  40. }