PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Domain / Factory / Notification / NotificationFactory.php
ameliabooking / src / Domain / Factory / Notification Last commit date
NotificationFactory.php 2 years ago NotificationLogFactory.php 4 years ago
NotificationFactory.php
87 lines
1 <?php
2
3 namespace AmeliaBooking\Domain\Factory\Notification;
4
5 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
6 use AmeliaBooking\Domain\Entity\Notification\Notification;
7 use AmeliaBooking\Domain\ValueObjects\BooleanValueObject;
8 use AmeliaBooking\Domain\ValueObjects\DateTime\TimeOfDay;
9 use AmeliaBooking\Domain\ValueObjects\Duration;
10 use AmeliaBooking\Domain\ValueObjects\Json;
11 use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id;
12 use AmeliaBooking\Domain\ValueObjects\String\BookingType;
13 use AmeliaBooking\Domain\ValueObjects\String\Html;
14 use AmeliaBooking\Domain\ValueObjects\String\Name;
15 use AmeliaBooking\Domain\ValueObjects\String\NotificationSendTo;
16 use AmeliaBooking\Domain\ValueObjects\String\NotificationStatus;
17 use AmeliaBooking\Domain\ValueObjects\String\NotificationType;
18
19 /**
20 * Class NotificationFactory
21 *
22 * @package AmeliaBooking\Domain\Factory\Notification
23 */
24 class NotificationFactory
25 {
26 /**
27 * @param array $data
28 *
29 * @return Notification
30 * @throws InvalidArgumentException
31 */
32 public static function create($data)
33 {
34 $notification = new Notification(
35 new Name($data['name']),
36 new NotificationStatus($data['status']),
37 new NotificationType($data['type']),
38 new BookingType($data['entity']),
39 new NotificationSendTo($data['sendTo']),
40 new Name($data['subject']),
41 new Html($data['content'])
42 );
43
44 if (isset($data['id'])) {
45 $notification->setId(new Id($data['id']));
46 }
47
48 if (isset($data['customName']) && !empty($data['customName'])) {
49 $notification->setCustomName($data['customName']);
50 }
51
52 if (isset($data['time'])) {
53 $notification->setTime(new TimeOfDay($data['time']));
54 }
55
56 if (isset($data['timeBefore'])) {
57 $notification->setTimeBefore(new Duration($data['timeBefore']));
58 }
59
60 if (isset($data['translations'])) {
61 $notification->setTranslations(new Json($data['translations']));
62 }
63
64 if (isset($data['timeAfter'])) {
65 $notification->setTimeAfter(new Duration($data['timeAfter']));
66 }
67
68 if (isset($data['entityIds'])) {
69 $notification->setEntityIds(($data['entityIds']));
70 }
71
72 if (isset($data['sendOnlyMe']) && !empty($data['sendOnlyMe'])) {
73 $notification->setSendOnlyMe(new BooleanValueObject($data['sendOnlyMe']));
74 }
75
76 if (isset($data['whatsAppTemplate'])) {
77 $notification->setWhatsAppTemplate($data['whatsAppTemplate']);
78 }
79
80 if (isset($data['minimumTimeBeforeBooking'])) {
81 $notification->setMinimumTimeBeforeBooking(new Json($data['minimumTimeBeforeBooking']));
82 }
83
84 return $notification;
85 }
86 }
87