Passed
Branch master (a006bc)
by Vitaliy
05:17 queued 02:53
created

Jwt   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 18.31 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 13
loc 71
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 13 13 3
A getTeamId() 0 4 1
A getKey() 0 4 1
A getPath() 0 4 1

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\Jwt;
15
16
use Apple\ApnPush\Exception\CertificateFileNotFoundException;
17
18
/**
19
 * Default Json Web Token for authenticate in provider of apn push service
20
 */
21
class Jwt implements JwtInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    private $teamId;
27
28
    /**
29
     * @var string
30
     */
31
    private $key;
32
33
    /**
34
     * @var string
35
     */
36
    private $path;
37
38
    /**
39
     * Constructor.
40
     *
41
     * @param string $teamId
42
     * @param string $key
43
     * @param string $path
44
     *
45
     * @throws CertificateFileNotFoundException
46
     */
47 View Code Duplication
    public function __construct(string $teamId, string $key, string $path)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        if (!file_exists($path) || !is_file($path)) {
50
            throw new CertificateFileNotFoundException(sprintf(
51
                'The certificate file "%s" was not found.',
52
                $path
53
            ));
54
        }
55
56
        $this->teamId = $teamId;
57
        $this->key = $key;
58
        $this->path = $path;
59
    }
60
61
    /**
62
     * Get the identifier of team (Apple Developer)
63
     *
64
     * @return string
65
     */
66
    public function getTeamId(): string
67
    {
68
        return $this->teamId;
69
    }
70
71
    /**
72
     * Get the key of certificate
73
     * You can see the key of certificate in Apple Developer Center
74
     *
75
     * @return string
76
     */
77
    public function getKey(): string
78
    {
79
        return $this->key;
80
    }
81
82
    /**
83
     * Get the path to private certificate
84
     *
85
     * @return string
86
     */
87
    public function getPath(): string
88
    {
89
        return $this->path;
90
    }
91
}
92