1 | <?php |
||
18 | class Client |
||
19 | { |
||
20 | /** |
||
21 | * Array of notifications. |
||
22 | * |
||
23 | * @var Notification[] |
||
24 | */ |
||
25 | private $notifications = []; |
||
26 | |||
27 | /** |
||
28 | * Authentication provider. |
||
29 | * |
||
30 | * @var AuthProviderInterface |
||
31 | */ |
||
32 | private $authProvider; |
||
33 | |||
34 | /** |
||
35 | * Production or sandbox environment. |
||
36 | * |
||
37 | * @var bool |
||
38 | */ |
||
39 | private $isProductionEnv; |
||
40 | |||
41 | /** |
||
42 | * Number of concurrent requests to multiplex in the same connection. |
||
43 | * |
||
44 | * @var int |
||
45 | */ |
||
46 | private $nbConcurrentRequests = 20; |
||
47 | |||
48 | /** |
||
49 | * Number of maximum concurrent connections established to the APNS servers. |
||
50 | * |
||
51 | * @var int |
||
52 | */ |
||
53 | private $maxConcurrentConnections = 1; |
||
54 | |||
55 | /** |
||
56 | * Flag to know if we should automatically close connections to the APNS servers or keep them alive. |
||
57 | * |
||
58 | * @var bool |
||
59 | */ |
||
60 | private $autoCloseConnections = true; |
||
61 | |||
62 | /** |
||
63 | * Current curl_multi handle instance. |
||
64 | * |
||
65 | * @var Object |
||
66 | */ |
||
67 | private $curlMultiHandle; |
||
68 | |||
69 | /** |
||
70 | * Client constructor. |
||
71 | * |
||
72 | * @param AuthProviderInterface $authProvider |
||
73 | * @param bool $isProductionEnv |
||
74 | */ |
||
75 | public function __construct(AuthProviderInterface $authProvider, bool $isProductionEnv = false) |
||
80 | |||
81 | /** |
||
82 | * Push notifications to APNs. |
||
83 | * |
||
84 | * @return ApnsResponseInterface[] |
||
85 | */ |
||
86 | public function push(): array |
||
166 | |||
167 | /** |
||
168 | * Prepares a curl handle from a Notification object. |
||
169 | * |
||
170 | * @param Notification $notification |
||
171 | */ |
||
172 | private function prepareHandle(Notification $notification) |
||
187 | |||
188 | /** |
||
189 | * Add notification in queue for sending. |
||
190 | * |
||
191 | * @param Notification $notification |
||
192 | */ |
||
193 | public function addNotification(Notification $notification) |
||
197 | |||
198 | /** |
||
199 | * Add several notifications in queue for sending. |
||
200 | * |
||
201 | * @param Notification[] $notifications |
||
202 | */ |
||
203 | public function addNotifications(array $notifications) |
||
213 | |||
214 | /** |
||
215 | * Get already added notifications. |
||
216 | * |
||
217 | * @return Notification[] |
||
218 | */ |
||
219 | public function getNotifications(): array |
||
223 | |||
224 | /** |
||
225 | * Close the current curl multi handle. |
||
226 | */ |
||
227 | public function close() |
||
234 | |||
235 | /** |
||
236 | * Set the number of concurrent requests sent through the multiplexed connections. |
||
237 | * |
||
238 | * @param int $nbConcurrentRequests |
||
239 | */ |
||
240 | public function setNbConcurrentRequests($nbConcurrentRequests) |
||
244 | |||
245 | |||
246 | /** |
||
247 | * Set the number of maximum concurrent connections established to the APNS servers. |
||
248 | * |
||
249 | * @param int $nbConcurrentRequests |
||
250 | */ |
||
251 | public function setMaxConcurrentConnections($maxConcurrentConnections) |
||
255 | |||
256 | /** |
||
257 | * Set wether or not the client should automatically close the connections. Apple recommends keeping |
||
258 | * connections open if you send more than a few notification per minutes. |
||
259 | * |
||
260 | * @param bool $nbConcurrentRequests |
||
261 | */ |
||
262 | public function setAutoCloseConnections($autoCloseConnections) |
||
266 | } |
||
267 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..