Completed
Push — master ( 58620c...f23d9f )
by Vitaliy
02:20
created

AddPriorityHeaderVisitor::visit()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the AppleApnPush package
5
 *
6
 * (c) Vitaliy Zhuk <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code
10
 */
11
12
namespace Apple\ApnPush\Protocol\Http\Visitor;
13
14
use Apple\ApnPush\Model\Message;
15
use Apple\ApnPush\Protocol\Http\Request;
16
17
/**
18
 * Visitor for add priority header to request
19
 */
20
class AddPriorityHeaderVisitor implements HttpProtocolVisitorInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function visit(Message $message, Request $request) : Request
26
    {
27
        $priority = $message->getPriority();
28
29
        if (!$priority->isNull()) {
30
            $request = $request->withHeader('apns-priority', $priority->getValue());
31
        }
32
33
        return $request;
34
    }
35
}
36