| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @copyright © Melograno Venture Studio. All rights reserved. |
| 5 |
* @licence See LICENCE.md for license details. |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace IvyForms\Entity\Notification; |
| 9 |
|
| 10 |
// phpcs:disable PSR1.Files.SideEffects |
| 11 |
if (!defined('ABSPATH')) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
use IvyForms\ValueObjects\Notification\Notification as NotificationValueObject; |
| 16 |
|
| 17 |
/** |
| 18 |
* Class Notification |
| 19 |
* |
| 20 |
* @package IvyForms\Entity\Notification |
| 21 |
*/ |
| 22 |
class Notification |
| 23 |
{ |
| 24 |
/** |
| 25 |
* @var NotificationValueObject |
| 26 |
*/ |
| 27 |
private NotificationValueObject $notification; |
| 28 |
|
| 29 |
/** |
| 30 |
* Notification constructor. |
| 31 |
* |
| 32 |
* @param NotificationValueObject $notification The notification object. |
| 33 |
*/ |
| 34 |
public function __construct(NotificationValueObject $notification) |
| 35 |
{ |
| 36 |
$this->notification = $notification; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Get the notification ID. |
| 41 |
* |
| 42 |
* @return int |
| 43 |
*/ |
| 44 |
public function getId(): int |
| 45 |
{ |
| 46 |
return $this->notification->getId(); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Set the notification ID. |
| 51 |
* |
| 52 |
* @param int $id |
| 53 |
*/ |
| 54 |
public function setId(int $id): void |
| 55 |
{ |
| 56 |
$this->notification->id = $id; |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Get the notification name. |
| 61 |
* |
| 62 |
* @return string |
| 63 |
*/ |
| 64 |
public function getName(): string |
| 65 |
{ |
| 66 |
return $this->notification->getName(); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Set the notification name. |
| 71 |
* |
| 72 |
* @param string $name |
| 73 |
*/ |
| 74 |
public function setName(string $name): void |
| 75 |
{ |
| 76 |
$this->notification->name = $name; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Get the notification sender. |
| 81 |
* |
| 82 |
* @return string |
| 83 |
*/ |
| 84 |
public function getSender(): string |
| 85 |
{ |
| 86 |
return $this->notification->getSender(); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Set the notification sender. |
| 91 |
* |
| 92 |
* @param string $sender |
| 93 |
*/ |
| 94 |
public function setSender(string $sender): void |
| 95 |
{ |
| 96 |
$this->notification->sender = $sender; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Get the notification reply-to address. |
| 101 |
* |
| 102 |
* @return string |
| 103 |
*/ |
| 104 |
public function getReplyTo(): string |
| 105 |
{ |
| 106 |
return $this->notification->getReplyTo(); |
| 107 |
} |
| 108 |
|
| 109 |
/** |
| 110 |
* Set the notification reply-to address. |
| 111 |
* |
| 112 |
* @param string $replyTo |
| 113 |
*/ |
| 114 |
public function setReplyTo(string $replyTo): void |
| 115 |
{ |
| 116 |
$this->notification->replyTo = $replyTo; |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Get the notification receiver. |
| 121 |
* |
| 122 |
* @return string |
| 123 |
*/ |
| 124 |
public function getReceiver(): string |
| 125 |
{ |
| 126 |
return $this->notification->getReceiver(); |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* Set the notification receiver. |
| 131 |
* |
| 132 |
* @param string $receiver |
| 133 |
*/ |
| 134 |
public function setReceiver(string $receiver): void |
| 135 |
{ |
| 136 |
$this->notification->receiver = $receiver; |
| 137 |
} |
| 138 |
|
| 139 |
/** |
| 140 |
* Get the notification status. |
| 141 |
* |
| 142 |
* @return bool |
| 143 |
*/ |
| 144 |
public function isEnabled(): bool |
| 145 |
{ |
| 146 |
return $this->notification->isEnabled(); |
| 147 |
} |
| 148 |
|
| 149 |
/** |
| 150 |
* Set the notification status. |
| 151 |
* |
| 152 |
* @param bool $enabled |
| 153 |
*/ |
| 154 |
public function setEnabled(bool $enabled): void |
| 155 |
{ |
| 156 |
$this->notification->enabled = $enabled; |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
* Get the notification subject. |
| 161 |
* |
| 162 |
* @return string |
| 163 |
*/ |
| 164 |
public function getSubject(): string |
| 165 |
{ |
| 166 |
return $this->notification->getSubject(); |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* Set the notification subject. |
| 171 |
* |
| 172 |
* @param string $subject |
| 173 |
*/ |
| 174 |
public function setSubject(string $subject): void |
| 175 |
{ |
| 176 |
$this->notification->subject = $subject; |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* Get the notification message. |
| 181 |
* |
| 182 |
* @return string |
| 183 |
*/ |
| 184 |
public function getMessage(): string |
| 185 |
{ |
| 186 |
return $this->notification->getMessage(); |
| 187 |
} |
| 188 |
|
| 189 |
/** |
| 190 |
* Set the notification message. |
| 191 |
* |
| 192 |
* @param string $message |
| 193 |
*/ |
| 194 |
public function setMessage(string $message): void |
| 195 |
{ |
| 196 |
$this->notification->message = $message; |
| 197 |
} |
| 198 |
|
| 199 |
/** |
| 200 |
* Get the smart logic status. |
| 201 |
* |
| 202 |
* @return bool |
| 203 |
*/ |
| 204 |
public function isSmartLogic(): bool |
| 205 |
{ |
| 206 |
return $this->notification->isSmartLogic(); |
| 207 |
} |
| 208 |
|
| 209 |
/** |
| 210 |
* Set the smart logic status. |
| 211 |
* |
| 212 |
* @param bool $smartLogic |
| 213 |
*/ |
| 214 |
public function setSmartLogic(bool $smartLogic): void |
| 215 |
{ |
| 216 |
$this->notification->smartLogic = $smartLogic; |
| 217 |
} |
| 218 |
|
| 219 |
/** |
| 220 |
* Get the form ID. |
| 221 |
* |
| 222 |
* @return int |
| 223 |
*/ |
| 224 |
public function getFormId(): int |
| 225 |
{ |
| 226 |
return $this->notification->getFormId(); |
| 227 |
} |
| 228 |
|
| 229 |
/** |
| 230 |
* Set the form ID. |
| 231 |
* |
| 232 |
* @param int $formId |
| 233 |
*/ |
| 234 |
public function setFormId(int $formId): void |
| 235 |
{ |
| 236 |
$this->notification->formId = $formId; |
| 237 |
} |
| 238 |
|
| 239 |
/** |
| 240 |
* Convert the notification entity to an array. |
| 241 |
* |
| 242 |
* @return array<string, mixed> The notification entity as an array. |
| 243 |
*/ |
| 244 |
public function toArray(): array |
| 245 |
{ |
| 246 |
return [ |
| 247 |
'id' => $this->getId(), |
| 248 |
'name' => $this->getName(), |
| 249 |
'sender' => $this->getSender(), |
| 250 |
'replyTo' => $this->getReplyTo(), |
| 251 |
'receiver' => $this->getReceiver(), |
| 252 |
'enabled' => $this->isEnabled(), |
| 253 |
'subject' => $this->getSubject(), |
| 254 |
'message' => $this->getMessage(), |
| 255 |
'smartLogic' => $this->isSmartLogic(), |
| 256 |
'formId' => $this->getFormId(), |
| 257 |
]; |
| 258 |
} |
| 259 |
} |
| 260 |
|