src/Entity/Common/Confirmation.php line 13

  1. <?php
  2. namespace App\Entity\Common;
  3. use App\Entity\Olympiad\Online\Participant;
  4. use App\Entity\Traits\CreatedTrait;
  5. use App\Entity\Traits\UpdatedTrait;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Table(name'confirmations')]
  8. #[ORM\Entity]
  9. #[ORM\HasLifecycleCallbacks]
  10. class Confirmation
  11. {
  12.     use CreatedTrait;
  13.     use UpdatedTrait;
  14.     public const SEND_TIMEOUT 60 1;
  15.     public const VALIDATION_TIMEOUT 60 60;
  16.     public const TYPE_EMAIL 'email';
  17.     public const TYPE_PHONE 'phone';
  18.     #[ORM\Id]
  19.     #[ORM\Column(type'string'length36)]
  20.     private string $uuid;
  21.     #[ORM\Column(type'string'length36nullablefalse)]
  22.     private string $object_uuid;
  23.     #[ORM\Column(type'string')]
  24.     private string $type;
  25.     #[ORM\Column(type'string')]
  26.     private string $value;
  27.     #[ORM\Column(type'string')]
  28.     private string $code;
  29.     /**
  30.      * @var  string|null
  31.      */
  32.     #[ORM\Column(type'string'nullabletrue)]
  33.     private ?string $ip;
  34.     /**
  35.      * @var \DateTime
  36.      */
  37.     #[ORM\Column(type'datetime')]
  38.     private \DateTime $sentAt;
  39.     #[ORM\Column(type'boolean')]
  40.     private bool $confirmed false;
  41.     /**
  42.      * @return string
  43.      */
  44.     public function getType(): string
  45.     {
  46.         return $this->type;
  47.     }
  48.     /**
  49.      * @param string $type
  50.      */
  51.     public function setType(string $type): void
  52.     {
  53.         $this->type $type;
  54.     }
  55.     /**
  56.      * @return string
  57.      */
  58.     public function getValue(): string
  59.     {
  60.         return $this->value;
  61.     }
  62.     /**
  63.      * @param string $value
  64.      */
  65.     public function setValue(string $value): void
  66.     {
  67.         $this->value $value;
  68.     }
  69.     /**
  70.      * @return string
  71.      */
  72.     public function getCode(): string
  73.     {
  74.         return $this->code;
  75.     }
  76.     /**
  77.      * @param string $code
  78.      */
  79.     public function setCode(string $code): void
  80.     {
  81.         $this->code $code;
  82.     }
  83.     /**
  84.      * @return \DateTime
  85.      */
  86.     public function getSentAt(): \DateTime
  87.     {
  88.         return $this->sentAt;
  89.     }
  90.     /**
  91.      * @param \DateTime $sentAt
  92.      */
  93.     public function setSentAt(\DateTime $sentAt): void
  94.     {
  95.         $this->sentAt $sentAt;
  96.     }
  97.     /**
  98.      * @return bool
  99.      */
  100.     public function isConfirmed(): bool
  101.     {
  102.         return $this->confirmed;
  103.     }
  104.     /**
  105.      * @param bool $confirmed
  106.      */
  107.     public function setConfirmed(bool $confirmed): void
  108.     {
  109.         $this->confirmed $confirmed;
  110.     }
  111.     /**
  112.      * @return string
  113.      */
  114.     public function getUuid(): string
  115.     {
  116.         return $this->uuid;
  117.     }
  118.     /**
  119.      * @param string $uuid
  120.      */
  121.     public function setUuid(string $uuid): void
  122.     {
  123.         $this->uuid $uuid;
  124.     }
  125.     /**
  126.      * @return string|null
  127.      */
  128.     public function getIp(): ?string
  129.     {
  130.         return $this->ip;
  131.     }
  132.     /**
  133.      * @param string|null $ip
  134.      */
  135.     public function setIp(?string $ip): void
  136.     {
  137.         $this->ip $ip;
  138.     }
  139.     public function getValidTill(): \DateTime
  140.     {
  141.         $dateTime = clone($this->getSentAt());
  142.         return $dateTime->add(new \DateInterval(sprintf('PT%dS'self::VALIDATION_TIMEOUT)));
  143.     }
  144.     public function getNextSendTime(): \DateTime
  145.     {
  146.         $dateTime = clone($this->getSentAt());
  147.         return $dateTime->add(new \DateInterval(sprintf('PT%dS'self::SEND_TIMEOUT)));
  148.     }
  149.     /**
  150.      * @return string
  151.      */
  152.     public function getObjectUuid(): string
  153.     {
  154.         return $this->object_uuid;
  155.     }
  156.     /**
  157.      * @param string $object_uuid
  158.      */
  159.     public function setObjectUuid(string $object_uuid): void
  160.     {
  161.         $this->object_uuid $object_uuid;
  162.     }
  163. }