1 | <?php |
||
20 | abstract class MessageBase implements MessageInterface |
||
21 | { |
||
22 | /** |
||
23 | * Default modifier (a date/time string) |
||
24 | */ |
||
25 | const DEFAULT_EXPIRATION_TIME_MODIFIER = '4 weeks'; |
||
26 | |||
27 | /** |
||
28 | * A UNIX epoch date expressed in seconds (UTC) that identifies |
||
29 | * when the notification is no longer valid and can be discarded |
||
30 | * |
||
31 | * @var \DateTime |
||
32 | */ |
||
33 | protected $expirationTime; |
||
34 | |||
35 | /** |
||
36 | * An arbitrary, opaque value that identifies this notification. |
||
37 | * This identifier is used for reporting errors to your server |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $messageIdentifier; |
||
42 | |||
43 | /** |
||
44 | * Collection of recipient devices |
||
45 | * |
||
46 | * @var \ArrayIterator |
||
47 | */ |
||
48 | protected $recipientCollection; |
||
49 | |||
50 | /** |
||
51 | * @param array $data |
||
52 | */ |
||
53 | public function __construct(array $data = array()) |
||
68 | |||
69 | /** |
||
70 | * Checks if recipient`s token is valid |
||
71 | * |
||
72 | * @param string $token |
||
73 | * @return bool |
||
74 | * @throws InvalidArgumentException |
||
75 | */ |
||
76 | abstract public function validateRecipient($token); |
||
77 | |||
78 | /** |
||
79 | * @return \ArrayIterator |
||
80 | */ |
||
81 | public function getRecipientDeviceCollection() |
||
85 | |||
86 | /** |
||
87 | * @param \ArrayIterator $collection |
||
88 | * @return $this |
||
89 | */ |
||
90 | public function setRecipientDeviceCollection(\ArrayIterator $collection) |
||
96 | |||
97 | /** |
||
98 | * @param \ArrayIterator $collection |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function addRecipientIdentifiers(\ArrayIterator $collection) |
||
111 | |||
112 | /** |
||
113 | * @param string $deviceIdentifier |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function addRecipient($deviceIdentifier) |
||
123 | |||
124 | /** |
||
125 | * Gets number of recipients allowed for single notification |
||
126 | * |
||
127 | * @return int |
||
128 | */ |
||
129 | public function getMaxRecipientsPerMessage() |
||
133 | |||
134 | /** |
||
135 | * @return \DateTime |
||
136 | */ |
||
137 | public function getExpirationTime() |
||
144 | |||
145 | /** |
||
146 | * @param \DateTime $expirationTime |
||
147 | * @return $this |
||
148 | */ |
||
149 | public function setExpirationTime(\DateTime $expirationTime) |
||
154 | |||
155 | /** |
||
156 | * @return string |
||
157 | */ |
||
158 | public function getMessageIdentifier() |
||
162 | |||
163 | /** |
||
164 | * @param string $messageIdentifier |
||
165 | * @throws InvalidArgumentException |
||
166 | */ |
||
167 | public function setMessageIdentifier($messageIdentifier) |
||
174 | |||
175 | /** |
||
176 | * Bad method call exception |
||
177 | * |
||
178 | * @param string $name |
||
179 | * @throws BadMethodCallException |
||
180 | */ |
||
181 | protected function badMethodCallException($name) |
||
187 | |||
188 | /** |
||
189 | * Invalid argument exception |
||
190 | * |
||
191 | * @param string $parameterName |
||
192 | * @param string $expectedType |
||
193 | */ |
||
194 | protected function invalidArgumentException($parameterName, $expectedType) |
||
205 | |||
206 | /** |
||
207 | * Error handler for unknown property notification |
||
208 | * |
||
209 | * @param string $name |
||
210 | */ |
||
211 | public function __get($name) |
||
215 | |||
216 | /** |
||
217 | * Error handler for unknown property of notification |
||
218 | * |
||
219 | * @param string $name |
||
220 | * @param mixed $value |
||
221 | */ |
||
222 | public function __set($name, $value) |
||
226 | } |
||
227 |