|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace HMS\Entities; |
| 4 | + |
| 5 | +use Carbon\Carbon; |
| 6 | +use Doctrine\Common\Collections\ArrayCollection; |
| 7 | + |
| 8 | +class Email |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @var int |
| 12 | + */ |
| 13 | + protected $id; |
| 14 | + |
| 15 | + /** |
| 16 | + * @var array |
| 17 | + */ |
| 18 | + protected $toAddress; |
| 19 | + |
| 20 | + /** |
| 21 | + * @var string |
| 22 | + */ |
| 23 | + protected $subject; |
| 24 | + |
| 25 | + /** |
| 26 | + * @var string |
| 27 | + */ |
| 28 | + protected $body; |
| 29 | + |
| 30 | + /* |
| 31 | + * @var Carbon |
| 32 | + */ |
| 33 | + protected $sentAt; |
| 34 | + |
| 35 | + /** |
| 36 | + * @var \Doctrine\Common\Collections\Collection|Users[] |
| 37 | + */ |
| 38 | + protected $users; |
| 39 | + |
| 40 | + /** |
| 41 | + * @var ?Role |
| 42 | + */ |
| 43 | + protected $role; |
| 44 | + |
| 45 | + /** |
| 46 | + * Create a new email record. |
| 47 | + * @param array $toAddress Array of to adddress in format [ email => name] |
| 48 | + * @param string $subject |
| 49 | + * @param string $body |
| 50 | + */ |
| 51 | + public function __construct(array $toAddress, string $subject, string $body) |
| 52 | + { |
| 53 | + $this->toAddress = $toAddress; |
| 54 | + $this->subject = $subject; |
| 55 | + $this->body = $body; |
| 56 | + $this->users = new ArrayCollection(); |
| 57 | + $this->sentAt = Carbon::now(); |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Gets the value of id. |
| 62 | + * |
| 63 | + * @return int |
| 64 | + */ |
| 65 | + public function getId(): int |
| 66 | + { |
| 67 | + return $this->id; |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Gets the value of to. |
| 72 | + * |
| 73 | + * @return array |
| 74 | + */ |
| 75 | + public function getTo(): array |
| 76 | + { |
| 77 | + return $this->toAddress; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Sets the value of to. |
| 82 | + * |
| 83 | + * @param array $toAddress the to |
| 84 | + * |
| 85 | + * @return self |
| 86 | + */ |
| 87 | + public function setTo(array $toAddress): Email |
| 88 | + { |
| 89 | + $this->toAddress = $toAddress; |
| 90 | + |
| 91 | + return $this; |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Gets the value of subject. |
| 96 | + * |
| 97 | + * @return string |
| 98 | + */ |
| 99 | + public function getSubject() |
| 100 | + { |
| 101 | + return $this->subject; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Sets the value of subject. |
| 106 | + * |
| 107 | + * @param string $subject the subject |
| 108 | + * |
| 109 | + * @return self |
| 110 | + */ |
| 111 | + public function setSubject(string $subject): Email |
| 112 | + { |
| 113 | + $this->subject = $subject; |
| 114 | + |
| 115 | + return $this; |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Gets the value of body. |
| 120 | + * |
| 121 | + * @return string |
| 122 | + */ |
| 123 | + public function getBody(): string |
| 124 | + { |
| 125 | + return $this->body; |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Sets the value of body. |
| 130 | + * |
| 131 | + * @param string $body the body |
| 132 | + * |
| 133 | + * @return self |
| 134 | + */ |
| 135 | + public function setBody($body): Email |
| 136 | + { |
| 137 | + $this->body = $body; |
| 138 | + |
| 139 | + return $this; |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * Gets the value of sentAt. |
| 144 | + * |
| 145 | + * @return string |
| 146 | + */ |
| 147 | + public function getSentAt(): Carbon |
| 148 | + { |
| 149 | + return $this->sentAt; |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * Sets the value of sentAt. |
| 154 | + * |
| 155 | + * @param string $sentAt the sent at |
| 156 | + * |
| 157 | + * @return self |
| 158 | + */ |
| 159 | + public function setSentAt($sentAt): Email |
| 160 | + { |
| 161 | + $this->sentAt = $sentAt; |
| 162 | + |
| 163 | + return $this; |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Gets the value of users. |
| 168 | + * |
| 169 | + * @return \Doctrine\Common\Collections\Collection|Users[] |
| 170 | + */ |
| 171 | + public function getUsers() |
| 172 | + { |
| 173 | + return $this->users; |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | + * Gets the value of role. |
| 178 | + * |
| 179 | + * @return ?Role |
| 180 | + */ |
| 181 | + public function getRole() |
| 182 | + { |
| 183 | + return $this->role; |
| 184 | + } |
| 185 | + |
| 186 | + /** |
| 187 | + * Sets the value of role. |
| 188 | + * |
| 189 | + * @param ?Role $role the role |
| 190 | + * |
| 191 | + * @return self |
| 192 | + */ |
| 193 | + public function setRole(?Role $role): Email |
| 194 | + { |
| 195 | + $this->role = $role; |
| 196 | + |
| 197 | + return $this; |
| 198 | + } |
| 199 | +} |
0 commit comments