AddExpirationHeaderVisitor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 16
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A visit() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 expiration header to request
21
 */
22 View Code Duplication
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