src/Model/Autoresponder.php line 320

Open in your IDE?
  1. <?php
  2. namespace App\Model;
  3. class Autoresponder implements \JsonSerializable
  4. {
  5.     const NOT_ACTIVE_PREFIX '_NA_';
  6.     
  7.     private $id;
  8.     private $userName;
  9.     private $userDomain;
  10.     private $fromName;
  11.     private $fromEmail;
  12.     private $subject// type of subject prefix (Re: / Odp: / Reception of message: / user's prefix) or null if user has his own subject (kept in ownSubject variable)
  13.     private $ownSubject// user'a own subject
  14.     private $message;
  15.     private $copy;
  16.     private $copyLines;
  17.     private $activationType;
  18.     private $activeFrom;
  19.     private $activeFromHour;
  20.     private $activeFromMinute;
  21.     private $activeTo;
  22.     private $activeToHour;
  23.     private $activeToMinute;
  24.     private $periodWeeks;
  25.     private $periodDays;
  26.     private $periodHours;
  27.     private $messagesLimit;
  28.     private $active;
  29.     
  30.     /**
  31.      * @return mixed
  32.      */
  33.     public function getActiveFromHour()
  34.     {
  35.         return $this->activeFromHour;
  36.     }
  37.     /**
  38.      * @return mixed
  39.      */
  40.     public function getActiveFromMinute()
  41.     {
  42.         return $this->activeFromMinute;
  43.     }
  44.     /**
  45.      * @return mixed
  46.      */
  47.     public function getActiveToHour()
  48.     {
  49.         return $this->activeToHour;
  50.     }
  51.     /**
  52.      * @return mixed
  53.      */
  54.     public function getActiveToMinute()
  55.     {
  56.         return $this->activeToMinute;
  57.     }
  58.     /**
  59.      * @param mixed $activeFromHour
  60.      */
  61.     public function setActiveFromHour($activeFromHour)
  62.     {
  63.         $this->activeFromHour $activeFromHour;
  64.     }
  65.     /**
  66.      * @param mixed $activeFromMinute
  67.      */
  68.     public function setActiveFromMinute($activeFromMinute)
  69.     {
  70.         $this->activeFromMinute $activeFromMinute;
  71.     }
  72.     /**
  73.      * @param mixed $activeToHour
  74.      */
  75.     public function setActiveToHour($activeToHour)
  76.     {
  77.         $this->activeToHour $activeToHour;
  78.     }
  79.     /**
  80.      * @param mixed $activeToMinute
  81.      */
  82.     public function setActiveToMinute($activeToMinute)
  83.     {
  84.         $this->activeToMinute $activeToMinute;
  85.     }
  86.     public function __construct()
  87.     {
  88.         $this->active false;
  89.     }
  90.     public function getId() : int
  91.     {
  92.         return $this->id;
  93.     }
  94.     
  95.     public function setId($id): self
  96.     {
  97.         $this->id $id;
  98.         return $this;
  99.     }
  100.     
  101.     public function getUserName(): ?string
  102.     {
  103.         return $this->userName;
  104.     }
  105.     
  106.     public function setUserName(string $userName): self
  107.     {
  108.         $this->userName $userName;
  109.         
  110.         return $this;
  111.     }
  112.     
  113.     public function getUserDomain(): ?string
  114.     {
  115.         return $this->userDomain;
  116.     }
  117.     
  118.     public function setUserDomain(string $userDomain): self
  119.     {
  120.         $this->userDomain $userDomain;
  121.         
  122.         return $this;
  123.     }
  124.     
  125.     public function getFromName(): ?string
  126.     {
  127.         return $this->fromName;
  128.     }
  129.     
  130.     public function setFromName(string $fromName): self
  131.     {
  132.         $this->fromName $fromName;
  133.         
  134.         return $this;
  135.     }
  136.     
  137.     public function getFromEmail(): ?string
  138.     {
  139.         return $this->fromEmail;
  140.     }
  141.     
  142.     public function setFromEmail(string $fromEmail): self
  143.     {
  144.         $this->fromEmail $fromEmail;
  145.         
  146.         return $this;
  147.     }
  148.     
  149.     public function getSubject(): ?string
  150.     {
  151.         return $this->subject;
  152.     }
  153.     
  154.     public function setSubject(string $subject): self
  155.     {
  156.         $this->subject $subject;
  157.         
  158.         return $this;
  159.     }
  160.     
  161.     public function getOwnSubject(): ?string
  162.     {
  163.         return $this->ownSubject;
  164.     }
  165.     
  166.     public function setOwnSubject(string $subject): self
  167.     {
  168.         $this->ownSubject $subject;
  169.         
  170.         return $this;
  171.     }
  172.     public function getMessage(): ?string
  173.     {
  174.         return $this->message;
  175.     }
  176.     
  177.     public function setMessage(string $message): self
  178.     {
  179.         $this->message $message;
  180.         
  181.         return $this;
  182.     }
  183.     public function getCopy(): ?bool
  184.     {
  185.         return $this->copy;
  186.     }
  187.     
  188.     public function setCopy(bool $copy): self
  189.     {
  190.         $this->copy $copy;
  191.         
  192.         return $this;
  193.     }
  194.     
  195.     public function getCopyLines(): ?int
  196.     {
  197.         return $this->copyLines;
  198.     }
  199.     
  200.     public function setCopyLines(int $copyLines): self
  201.     {
  202.         $this->copyLines $copyLines;
  203.         return $this;
  204.     }
  205.     
  206.     public function getActivationType(): ?string
  207.     {
  208.         return $this->activationType;
  209.     }
  210.     
  211.     public function setActivationType(string $activationType): self
  212.     {
  213.         $this->activationType $activationType;
  214.         
  215.         return $this;
  216.     }
  217.     
  218.     public function getActiveFrom(): ?\DateTime
  219.     {
  220.         return $this->activeFrom;
  221.     }
  222.     
  223.     public function setActiveFrom(?\DateTime $activeFrom): self
  224.     {
  225.         $this->activeFrom $activeFrom;
  226.         
  227.         return $this;
  228.     }
  229.     
  230.     public function getActiveTo(): ?\DateTime
  231.     {
  232.         return $this->activeTo;
  233.     }
  234.     
  235.     public function setActiveTo(?\DateTime $activeTo): self
  236.     {
  237.         $this->activeTo $activeTo;
  238.         
  239.         return $this;
  240.     }
  241.     
  242.     public function getPeriodWeeks(): ?int
  243.     {
  244.         return $this->periodWeeks;
  245.     }
  246.     
  247.     public function setPeriodWeeks(int $periodWeeks): self
  248.     {
  249.         $this->periodWeeks $periodWeeks;
  250.         
  251.         return $this;
  252.     }
  253.     
  254.     public function getPeriodDays(): ?int
  255.     {
  256.         return $this->periodDays;
  257.     }
  258.     
  259.     public function setPeriodDays(int $periodDays): self
  260.     {
  261.         $this->periodDays $periodDays;
  262.         
  263.         return $this;
  264.     }
  265.     
  266.     public function getPeriodHours(): ?int
  267.     {
  268.         return $this->periodHours;
  269.     }
  270.     
  271.     public function setPeriodHours(int $periodHours): self
  272.     {
  273.         $this->periodHours $periodHours;
  274.         
  275.         return $this;
  276.     }
  277.     
  278.     public function getMessagesLimit(): ?int
  279.     {
  280.         return $this->messagesLimit;
  281.     }
  282.     
  283.     public function setMessagesLimit(int $messagesLimit): self
  284.     {
  285.         $this->messagesLimit $messagesLimit;
  286.         
  287.         return $this;
  288.     }
  289.     
  290.     public function getActive(): ?bool
  291.     {
  292.         return $this->active;
  293.     }
  294.     
  295.     public function setActive(bool $active): self
  296.     {
  297.         $this->active $active;
  298.         
  299.         return $this;
  300.     }
  301.     
  302.     public function timeLimit()
  303.     {
  304.         return ($this->periodWeeks 24 $this->periodDays 24 $this->periodHours) * 3600;
  305.     }
  306.     
  307.     public function jsonSerialize()
  308.     {
  309.         $vars get_object_vars($this);
  310.         return $vars;
  311.     }
  312.     
  313.     public function getActiveFromWithMinutes()
  314.     {
  315.         $af $this->getActiveFrom();
  316.         $af->setTime($this->getActiveFromHour(), $this->getActiveFromMinute());
  317.         return $af;
  318.     }
  319.     
  320.     public function getActiveToWithMinutes()
  321.     {
  322.         $at $this->getActiveTo();
  323.         $at->setTime($this->getActiveToHour(), $this->getActiveToMinute());
  324.         return $at;
  325.     }
  326.     
  327.     public static function timelimitSplit(int $timelimit) : Array
  328.     {
  329.         $hours $timelimit 3600;
  330.         $days 0;
  331.         $weeks 0;
  332.         
  333.         if($hours >= 24) {
  334.             $days = (int) ($hours 24);
  335.         }
  336.         
  337.         if($days >= 7) {
  338.             $weeks = (int)($days 7);
  339.             $days $days - ($weeks 7);
  340.         }
  341.         
  342.         $hours $hours - ($days 24) - ($weeks 24 7);
  343.         
  344.         $arr = [];
  345.         $arr['weeks'] = $weeks;
  346.         $arr['days'] = $days;
  347.         $arr['hours'] = $hours;
  348.         
  349.         return $arr;
  350.     }
  351.     
  352.     
  353.     
  354. }