AddApnIdHeaderVisitor::visit()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the AppleApnPush package
7
 *
8
 * (c) Vitaliy Zhuk <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace Apple\ApnPush\Protocol\Http\Visitor;
15
16
use Apple\ApnPush\Model\Notification;
17
use Apple\ApnPush\Protocol\Http\Request;
18
19
/**
20
 * Visitor for add apn id header visitor
21
 */
22 View Code Duplication
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