src/Service/CIC/Legacy/Batchmailer/EmailQueueItem.php line 5

Open in your IDE?
  1. <?php
  2. namespace App\Service\CIC\Legacy\Batchmailer;
  3. class EmailQueueItem implements \Serializable\JsonSerializable
  4. {
  5.     private $id;
  6.     private $cid;
  7.     private $queue;
  8.     private $createdAt;
  9.     private $recipients = [];
  10.     private $senderName NULL;
  11.     private $replacements = [];
  12.     private $releaseAt NULL;
  13.     private $statusCode NULL;
  14.     private $statusText NULL;
  15.     private $firstAttemptedAt NULL;
  16.     private $lastAttemptedAt NULL;
  17.     private $attempts 0;
  18.     private $send_log NULL;
  19.     private $send_code NULL;
  20.     private $mta 'unknown';
  21.     private $thawAt NULL;
  22.     private $trackingCode NULL;
  23.     private $referenceCode NULL;
  24.     private $referenceType NULL;
  25.     private $attachment_uri NULL;
  26.     private $extra NULL;
  27.     private $extraData = [];
  28.     public function __construct(?string $data=null) {
  29.         if($data)
  30.             $this->unserialize($data);
  31.         if (empty($this->cid))
  32.             $this->cid bin2hex(random_bytes(16));
  33.         if (empty($this->createdOn))
  34.             $this->createdAt = new \DateTime();
  35.         if (empty($this->releaseAt))
  36.             $this->releaseAt = new \DateTime();
  37.         if (empty($this->firstAttemptedAt))
  38.             $this->firstAttemptedAt = new \DateTime();
  39.         if (empty($this->lastAttemptedAt))
  40.             $this->lastAttemptedAt = new \DateTime();
  41.         if (empty($this->thawAt))
  42.             $this->thawAt = new \DateTime();
  43.         if (empty($this->trackingCode))
  44.             $this->trackingCode bin2hex(random_bytes(44));
  45.         if (empty($this->statusText))
  46.             $this->statusText "STAGGED";
  47.     }
  48.     public function jsonSerialize()
  49.     {
  50.         return get_object_vars($this);
  51.     }
  52.     public function serialize(){
  53.         return serialize(get_object_vars($this));
  54.     }
  55.     public function unserialize($serialized)
  56.     {
  57.         $properties=get_object_vars($this);
  58.         $obj=json_decode($serialized);
  59.         if(!is_object($obj))
  60.             return;
  61.         foreach($properties as $property=>$value) {
  62.             if(property_exists($obj,$property)) {
  63.                 $this->$property=$obj->$property;
  64.             }
  65.         }
  66.     }
  67.     public function __toString()
  68.     {
  69.         return json_encode($this);
  70.     }
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getCid(): ?string
  76.     {
  77.         return $this->cid;
  78.     }
  79.     public function getQueue(): ?string
  80.     {
  81.         return $this->queue;
  82.     }
  83.     public function setQueue(string $queue): self
  84.     {
  85.         $this->queue $queue;
  86.         return $this;
  87.     }
  88.     public function getCreatedAt(): ?\DateTimeInterface
  89.     {
  90.         return $this->createdAt;
  91.     }
  92.     public function getRecipients(): ?array
  93.     {
  94.         return $this->recipients;
  95.     }
  96.     public function setRecipients(array $recipients): self
  97.     {
  98.         $this->recipients $recipients;
  99.         return $this;
  100.     }
  101.     public function getSenderName(): ?string
  102.     {
  103.         return $this->senderName;
  104.     }
  105.     public function setSenderName(string $senderName): self
  106.     {
  107.         $this->senderName $senderName;
  108.         return $this;
  109.     }
  110.     public function getReplacements(): ?array
  111.     {
  112.         return $this->replacements;
  113.     }
  114.     public function setReplacements(array $replacements): self
  115.     {
  116.         $this->replacements $replacements;
  117.         return $this;
  118.     }
  119.     public function getReleaseAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->releaseAt;
  122.     }
  123.     public function setReleaseAt(\DateTimeInterface $releaseAt): self
  124.     {
  125.         $this->releaseAt $releaseAt;
  126.         return $this;
  127.     }
  128.     public function getStatusCode(): ?int
  129.     {
  130.         return $this->statusCode;
  131.     }
  132.     public function setStatusCode(int $statusCode): self
  133.     {
  134.         $this->statusCode $statusCode;
  135.         return $this;
  136.     }
  137.     public function getStatusText(): ?string
  138.     {
  139.         return $this->statusText;
  140.     }
  141.     public function setStatusText(string $statusText): self
  142.     {
  143.         $this->statusText $statusText;
  144.         return $this;
  145.     }
  146.     public function getFirstAttemptedAt(): ?\DateTimeInterface
  147.     {
  148.         return $this->firstAttemptedAt;
  149.     }
  150.     public function getLastAttemptedAt(): ?\DateTimeInterface
  151.     {
  152.         return $this->lastAttemptedAt;
  153.     }
  154.     public function getAttempts(): ?int
  155.     {
  156.         return $this->attempts;
  157.     }
  158.     public function getSendLog(): ?string
  159.     {
  160.         return $this->send_log;
  161.     }
  162.     public function getSendCode(): ?string
  163.     {
  164.         return $this->send_code;
  165.     }
  166.     public function getMta(): ?string
  167.     {
  168.         return $this->mta;
  169.     }
  170.     public function setMta(string $mta): self
  171.     {
  172.         $this->mta $mta;
  173.         return $this;
  174.     }
  175.     public function getThawAt(): ?\DateTimeInterface
  176.     {
  177.         return $this->thawAt;
  178.     }
  179.     public function getTrackingCode(): ?string
  180.     {
  181.         return $this->trackingCode;
  182.     }
  183.     public function setTrackingCode(string $trackingCode): self
  184.     {
  185.         $this->trackingCode $trackingCode;
  186.         return $this;
  187.     }
  188.     public function getReferenceCode(): ?string
  189.     {
  190.         return $this->referenceCode;
  191.     }
  192.     public function setReferenceCode(string $referenceCode): self
  193.     {
  194.         $this->referenceCode $referenceCode;
  195.         return $this;
  196.     }
  197.     public function getReferenceType(): ?string
  198.     {
  199.         return $this->referenceType;
  200.     }
  201.     public function setReferenceType(string $referenceType): self
  202.     {
  203.         $this->referenceType $referenceType;
  204.         return $this;
  205.     }
  206.     public function setFirstAttemptedAt($firstAttemptedAt): self
  207.     {
  208.         $this->firstAttemptedAt $firstAttemptedAt;
  209.         return $this;
  210.     }
  211.     public function setLastAttemptedAt($lastAttemptedAt): self
  212.     {
  213.         $this->lastAttemptedAt $lastAttemptedAt;
  214.         return $this;
  215.     }
  216.     public function setAttempts(int $attempts): self
  217.     {
  218.         $this->attempts $attempts;
  219.         return $this;
  220.     }
  221.     public function setSendLog($send_log): self
  222.     {
  223.         $this->send_log $send_log;
  224.         return $this;
  225.     }
  226.     public function setSendCode($send_code): self
  227.     {
  228.         $this->send_code $send_code;
  229.         return $this;
  230.     }
  231.     public function setThawAt($thawAt): self
  232.     {
  233.         $this->thawAt $thawAt;
  234.         return $this;
  235.     }
  236.     public function setId($id): self
  237.     {
  238.         $this->id $id;
  239.         return $this;
  240.     }
  241.     public function setCid($cid): self
  242.     {
  243.         $this->cid $cid;
  244.         return $this;
  245.     }
  246.     public function setCreatedAt(\DateTime $createdAt): self
  247.     {
  248.         $this->createdAt $createdAt;
  249.         return $this;
  250.     }
  251.     public function getAttachmentUri()
  252.     {
  253.         return $this->attachment_uri;
  254.     }
  255.     public function setAttachmentUri($attachment_uri): self
  256.     {
  257.         $this->attachment_uri $attachment_uri;
  258.         return $this;
  259.     }
  260.     public function getExtra()
  261.     {
  262.         return $this->extra;
  263.     }
  264.     public function setExtra($extra): self
  265.     {
  266.         $this->extra $extra;
  267.         return $this;
  268.     }
  269.     public function getExtraData(): array
  270.     {
  271.         return $this->extraData;
  272.     }
  273.     public function setExtraData(array $extraData): self
  274.     {
  275.         $this->extraData $extraData;
  276.         return $this;
  277.     }
  278. }