Certificate   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 22.64 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 12
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 12 12 3
A getPath() 0 4 1
A getPassPhrase() 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\Certificate;
15
16
use Apple\ApnPush\Exception\CertificateFileNotFoundException;
17
18
/**
19
 * Base certificate
20
 */
21
class Certificate implements CertificateInterface
22
{
23
    /**
24
     * @var string
25
     */
26
    private $path;
27
28
    /**
29
     * @var string
30
     */
31
    private $passPhrase;
32
33
    /**
34
     * Construct
35
     *
36
     * @param string $path
37
     * @param string $passPhrase
38
     *
39
     * @throws CertificateFileNotFoundException
40
     */
41 View Code Duplication
    public function __construct(string $path, string $passPhrase)
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...
42
    {
43
        if (!\file_exists($path) || !\is_file($path)) {
44
            throw new CertificateFileNotFoundException(\sprintf(
45
                'The certificate file "%s" was not found.',
46
                $path
47
            ));
48
        }
49
50
        $this->path = $path;
51
        $this->passPhrase = $passPhrase;
52
    }
53
54
    /**
55
     * Get path
56
     *
57
     * @return string
58
     */
59
    public function getPath(): string
60
    {
61
        return $this->path;
62
    }
63
64
    /**
65
     * Get pass phrase
66
     *
67
     * @return string
68
     */
69
    public function getPassPhrase(): string
70
    {
71
        return $this->passPhrase;
72
    }
73
}
74