1 | <?php |
||
15 | class FcmAdapter implements AdapterInterface |
||
16 | { |
||
17 | |||
18 | use InstanceConfigTrait; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $tokens = []; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $notification = []; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $datas = []; |
||
34 | |||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $parameters = []; |
||
39 | |||
40 | /** |
||
41 | * Default config |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $_defaultConfig = [ |
||
46 | 'parameters' => [ |
||
47 | 'collapse_key' => null, |
||
48 | 'priority' => 'normal', |
||
49 | 'dry_run' => false, |
||
50 | 'time_to_live' => 0, |
||
51 | 'restricted_package_name' => null |
||
52 | ], |
||
53 | 'http' => [] |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * List of keys allowed to be used in notification array. |
||
58 | * |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $_allowedNotificationParameters = [ |
||
62 | 'title', |
||
63 | 'body', |
||
64 | 'icon', |
||
65 | 'sound', |
||
66 | 'badge', |
||
67 | 'tag', |
||
68 | 'color', |
||
69 | 'click_action', |
||
70 | 'body_loc_key', |
||
71 | 'body_loc_args', |
||
72 | 'title_loc_key', |
||
73 | 'title_loc_args', |
||
74 | ]; |
||
75 | |||
76 | /** |
||
77 | * FcmAdapter constructor. |
||
78 | * @param array $config |
||
79 | * @throws \kerox\Push\Exception\InvalidAdapterException |
||
80 | */ |
||
81 | public function __construct(array $config = []) |
||
90 | |||
91 | /** |
||
92 | * @return bool |
||
93 | */ |
||
94 | public function send() |
||
98 | |||
99 | /** |
||
100 | * |
||
101 | */ |
||
102 | public function response() |
||
106 | |||
107 | /** |
||
108 | * @return array |
||
109 | */ |
||
110 | public function getTokens(): array |
||
114 | |||
115 | /** |
||
116 | * @param array $tokens |
||
117 | * @return $this |
||
118 | */ |
||
119 | public function setTokens(array $tokens) |
||
126 | |||
127 | /** |
||
128 | * @return array |
||
129 | */ |
||
130 | public function getNotification(): array |
||
134 | |||
135 | /** |
||
136 | * @param array $notification |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function setNotification(array $notification) |
||
149 | |||
150 | /** |
||
151 | * @return array |
||
152 | */ |
||
153 | public function getDatas(): array |
||
157 | |||
158 | /** |
||
159 | * @param array $datas |
||
160 | * @return $this |
||
161 | */ |
||
162 | public function setDatas(array $datas) |
||
175 | |||
176 | /** |
||
177 | * @return array |
||
178 | */ |
||
179 | public function getParameters(): array |
||
183 | |||
184 | /** |
||
185 | * @param array $parameters |
||
186 | * @return $this |
||
187 | */ |
||
188 | public function setParameters(array $parameters) |
||
195 | |||
196 | /** |
||
197 | * @param $tokens |
||
198 | * @return void |
||
199 | * @throws \ker0x\Push\Exception\InvalidTokenException |
||
200 | */ |
||
201 | private function _checkTokens($tokens) |
||
207 | |||
208 | /** |
||
209 | * @param $notification |
||
210 | * @return void |
||
211 | * @throws \ker0x\Push\Exception\InvalidNotificationException |
||
212 | */ |
||
213 | private function _checkNotification($notification) |
||
231 | |||
232 | /** |
||
233 | * @param $datas |
||
234 | * @return void |
||
235 | * @throws \ker0x\Push\Exception\InvalidDataException |
||
236 | */ |
||
237 | private function _checkDatas($datas) |
||
243 | |||
244 | /** |
||
245 | * @param $parameters |
||
246 | * @return void |
||
247 | * @throws \ker0x\Push\Exception\InvalidParametersException |
||
248 | */ |
||
249 | private function _checkParameters($parameters) |
||
255 | |||
256 | /** |
||
257 | * @return bool |
||
258 | */ |
||
259 | private function _executePush() |
||
269 | |||
270 | /** |
||
271 | * |
||
272 | */ |
||
273 | private function _buildPayload() |
||
285 | |||
286 | /** |
||
287 | * |
||
288 | */ |
||
289 | private function _buildMessage() |
||
305 | |||
306 | /** |
||
307 | * Return options for the HTTP request |
||
308 | * |
||
309 | * @throws \Exception |
||
310 | * @return array $options |
||
311 | */ |
||
312 | private function _getHttpOptions() |
||
324 | } |
||
325 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.