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 | * Collection of recipient devices |
||
37 | * |
||
38 | * @var \ArrayIterator |
||
39 | */ |
||
40 | protected $recipientCollection; |
||
41 | |||
42 | /** |
||
43 | * @param array $data |
||
44 | */ |
||
45 | public function __construct(array $data = array()) |
||
59 | |||
60 | /** |
||
61 | * Checks if recipient`s token is valid |
||
62 | * |
||
63 | * @param string $token |
||
64 | * @return bool |
||
65 | * @throws InvalidArgumentException |
||
66 | */ |
||
67 | abstract public function validateRecipient($token); |
||
68 | |||
69 | /** |
||
70 | * @return \ArrayIterator |
||
71 | */ |
||
72 | public function getRecipientDeviceCollection() |
||
76 | |||
77 | /** |
||
78 | * @param \ArrayIterator $collection |
||
79 | * @return $this |
||
80 | */ |
||
81 | public function setRecipientDeviceCollection(\ArrayIterator $collection) |
||
87 | |||
88 | /** |
||
89 | * @param \ArrayIterator $collection |
||
90 | * @return $this |
||
91 | */ |
||
92 | public function addRecipientIdentifiers(\ArrayIterator $collection) |
||
104 | |||
105 | /** |
||
106 | * @param string $deviceIdentifier |
||
107 | * @return $this |
||
108 | */ |
||
109 | public function addRecipient($deviceIdentifier) |
||
116 | |||
117 | /** |
||
118 | * Gets number of recipients allowed for single notification |
||
119 | * |
||
120 | * @return int |
||
121 | */ |
||
122 | public function getMaxRecipientsPerMessage() |
||
126 | |||
127 | /** |
||
128 | * @return \DateTime |
||
129 | */ |
||
130 | public function getExpirationTime() |
||
137 | |||
138 | /** |
||
139 | * @param \DateTime $expirationTime |
||
140 | * @return $this |
||
141 | */ |
||
142 | public function setExpirationTime(\DateTime $expirationTime) |
||
147 | |||
148 | /** |
||
149 | * Bad method call exception |
||
150 | * |
||
151 | * @param string $name |
||
152 | * @throws BadMethodCallException |
||
153 | */ |
||
154 | protected function badMethodCallException($name) |
||
160 | |||
161 | /** |
||
162 | * Invalid argument exception |
||
163 | * |
||
164 | * @param string $parameterName |
||
165 | * @param string $expectedType |
||
166 | */ |
||
167 | protected function invalidArgumentException($parameterName, $expectedType) |
||
178 | |||
179 | /** |
||
180 | * Error handler for unknown property notification |
||
181 | * |
||
182 | * @param string $name |
||
183 | */ |
||
184 | public function __get($name) |
||
188 | |||
189 | /** |
||
190 | * Error handler for unknown property of notification |
||
191 | * |
||
192 | * @param string $name |
||
193 | * @param mixed $value |
||
194 | */ |
||
195 | public function __set($name, $value) |
||
199 | } |
||
200 |