src/Entity/Olympiad/Online/Participant/Confirmation.php line 13

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