| @@ 22-37 (lines=16) @@ | ||
| 19 | /** |
|
| 20 | * Visitor for add expiration header to request |
|
| 21 | */ |
|
| 22 | class AddExpirationHeaderVisitor implements HttpProtocolVisitorInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | public function visit(Notification $notification, Request $request): Request |
|
| 28 | { |
|
| 29 | $expiration = $notification->getExpiration(); |
|
| 30 | ||
| 31 | if ($expiration) { |
|
| 32 | $request = $request->withHeader('apns-expiration', (string) $expiration->getValue()); |
|
| 33 | } |
|
| 34 | ||
| 35 | return $request; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 22-37 (lines=16) @@ | ||
| 19 | /** |
|
| 20 | * Visitor for add priority header to request |
|
| 21 | */ |
|
| 22 | class AddPriorityHeaderVisitor implements HttpProtocolVisitorInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | public function visit(Notification $notification, Request $request): Request |
|
| 28 | { |
|
| 29 | $priority = $notification->getPriority(); |
|
| 30 | ||
| 31 | if ($priority) { |
|
| 32 | $request = $request->withHeader('apns-priority', (string) $priority->getValue()); |
|
| 33 | } |
|
| 34 | ||
| 35 | return $request; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 22-37 (lines=16) @@ | ||
| 19 | /** |
|
| 20 | * Visitor for add apn id header visitor |
|
| 21 | */ |
|
| 22 | class AddApnIdHeaderVisitor implements HttpProtocolVisitorInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | public function visit(Notification $notification, Request $request): Request |
|
| 28 | { |
|
| 29 | $apnId = $notification->getApnId(); |
|
| 30 | ||
| 31 | if ($apnId) { |
|
| 32 | $request = $request->withHeader('apns-id', $apnId->getValue()); |
|
| 33 | } |
|
| 34 | ||
| 35 | return $request; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 22-37 (lines=16) @@ | ||
| 19 | /** |
|
| 20 | * Visitor for add the apns-collapse-id header. |
|
| 21 | */ |
|
| 22 | class AddCollapseIdHeaderVisitor implements HttpProtocolVisitorInterface |
|
| 23 | { |
|
| 24 | /** |
|
| 25 | * {@inheritdoc} |
|
| 26 | */ |
|
| 27 | public function visit(Notification $notification, Request $request): Request |
|
| 28 | { |
|
| 29 | $collapseId = $notification->getCollapseId(); |
|
| 30 | ||
| 31 | if ($collapseId) { |
|
| 32 | $request = $request->withHeader('apns-collapse-id', $collapseId->getValue()); |
|
| 33 | } |
|
| 34 | ||
| 35 | return $request; |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||