1 | <?php |
||
20 | class NotificationBuilder |
||
21 | { |
||
22 | /** |
||
23 | * @var PayloadHandlerInterface[] |
||
24 | */ |
||
25 | private $payloadHandlers; |
||
26 | |||
27 | /** |
||
28 | * @var MessageInterface |
||
29 | */ |
||
30 | private $message; |
||
31 | |||
32 | /** |
||
33 | * @var \ArrayIterator |
||
34 | */ |
||
35 | private $notifications; |
||
36 | |||
37 | /** |
||
38 | * @param PayloadHandlerInterface $handler |
||
39 | * @return $this |
||
40 | */ |
||
41 | public function addPayloadHandler(PayloadHandlerInterface $handler) |
||
51 | |||
52 | /** |
||
53 | * @return Notification|null |
||
54 | */ |
||
55 | public function getNotification() |
||
66 | |||
67 | /** |
||
68 | * Generates number of notifications by message recipient count |
||
69 | * and notification service limitations |
||
70 | * |
||
71 | * @param MessageInterface $message |
||
72 | * @return $this |
||
73 | */ |
||
74 | public function buildNotifications(MessageInterface $message) |
||
102 | |||
103 | /** |
||
104 | * Returns created notification |
||
105 | * |
||
106 | * @param \ArrayIterator $recipients |
||
107 | * @return Notification |
||
108 | * @throws MalformedNotificationException |
||
109 | */ |
||
110 | private function createNotification(\ArrayIterator $recipients) |
||
136 | |||
137 | /** |
||
138 | * @param PayloadHandlerInterface $handler |
||
139 | * @param MessageInterface $message |
||
140 | * @return string |
||
141 | * @throws MalformedNotificationException |
||
142 | */ |
||
143 | private function handlePayload(PayloadHandlerInterface $handler, MessageInterface $message) |
||
154 | |||
155 | /** |
||
156 | * Check if maximum size allowed for a notification payload exceeded |
||
157 | * |
||
158 | * @param PayloadHandlerInterface $handler |
||
159 | * @param string $payload |
||
160 | * @throws MalformedNotificationException |
||
161 | */ |
||
162 | private function validatePayload(PayloadHandlerInterface $handler, $payload) |
||
179 | } |
||
180 |