1 | <?php |
||
20 | class Request |
||
21 | { |
||
22 | const APNS_DEVELOPMENT_SERVER = 'https://api.development.push.apple.com'; |
||
23 | const APNS_PRODUCTION_SERVER = 'https://api.push.apple.com'; |
||
24 | const APNS_PORT = 443; |
||
25 | const APNS_PATH_SCHEMA = '/3/device/{token}'; |
||
26 | |||
27 | const HEADER_APNS_ID = 'apns-id'; |
||
28 | const HEADER_APNS_EXPIRATION = 'apns-expiration'; |
||
29 | const HEADER_APNS_PRIORITY = 'apns-priority'; |
||
30 | const HEADER_APNS_TOPIC = 'apns-topic'; |
||
31 | const HEADER_APNS_COLLAPSE_ID = 'apns-collapse-id'; |
||
32 | |||
33 | /** |
||
34 | * Request headers. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | private $headers = []; |
||
39 | |||
40 | /** |
||
41 | * Curl options. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | private $options = []; |
||
46 | |||
47 | public function __construct(Notification $notification, $isProductionEnv) |
||
68 | |||
69 | /** |
||
70 | * Add curl options. |
||
71 | * |
||
72 | * @param int $key |
||
73 | * @param $value |
||
74 | * @return Request |
||
75 | */ |
||
76 | public function addOption(int $key, $value): Request |
||
82 | |||
83 | /** |
||
84 | * Add curl options. |
||
85 | * |
||
86 | * @param array $options |
||
87 | * @return Request |
||
88 | */ |
||
89 | public function addOptions(array $options): Request |
||
95 | |||
96 | public function getOptions() |
||
100 | |||
101 | /** |
||
102 | * Add request header. |
||
103 | * |
||
104 | * @param string $header |
||
105 | */ |
||
106 | public function addHeader(string $header) |
||
110 | |||
111 | /** |
||
112 | * Add request headers. |
||
113 | * |
||
114 | * @param Notification[] $headers |
||
115 | */ |
||
116 | public function addHeaders(array $headers) |
||
120 | |||
121 | /** |
||
122 | * Get request headers. |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | public function getHeaders(): array |
||
130 | |||
131 | private function getProductionUrl(Notification $notification) |
||
135 | |||
136 | private function getSandboxUrl(Notification $notification) |
||
140 | |||
141 | private function getUrlPath(Notification $notification) |
||
145 | |||
146 | private function prepareApnsHeaders(Notification $notification) |
||
164 | |||
165 | } |
||
166 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: