GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#35)
by VEBER
01:56
created

CertificateNode   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 73
loc 73
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A addCertificate() 4 4 1
A retrieveCertificate() 4 4 1
A listCertificates() 4 4 1
A updateCertificate() 4 4 1
A updateOrCreateCertificate() 4 4 1
A deleteCertificate() 4 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
/*
4
 * This file is part of the KongAdminApi package.
5
 *
6
 * (c) Unikorp <https://github.com/unikorp>
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 Unikorp\KongAdminApi\Node;
13
14
use Psr\Http\Message\ResponseInterface;
15
use Unikorp\KongAdminApi\AbstractNode;
16
use Unikorp\KongAdminApi\Document\CertificateDocument as Document;
17
18
/**
19
 * certificate node
20
 *
21
 * @author VEBER Arnaud <https://github.com/VEBERArnaud>
22
 */
23 View Code Duplication
class CertificateNode extends AbstractNode
0 ignored issues
show
Duplication introduced by
This class 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...
24
{
25
    /**
26
     * add certificate
27
     *
28
     * @param \Unikorp\KongAdminApi\Document\CertificateDocument $document
29
     *
30
     * @return \Psr\Http\Message\ResponseInterface
31
     */
32 2
    public function addCertificate(Document $document): ResponseInterface
33
    {
34 2
        return $this->post('/certificates/', $document);
35
    }
36
37
    /**
38
     * retrieve certificate
39
     *
40
     * @param string $sniOrId
41
     *
42
     * @return \Psr\Http\Message\ResponseInterface
43
     */
44 1
    public function retrieveCertificate(string $sniOrId): ResponseInterface
45
    {
46 1
        return $this->get(sprintf('/certificates/%1$s', $sniOrId));
47
    }
48
49
    /**
50
     * list certificates
51
     *
52
     * @return \Psr\Http\Message\ResponseInterface
53
     */
54 2
    public function listCertificates(): ResponseInterface
55
    {
56 2
        return $this->get('/certificates/');
57
    }
58
59
    /**
60
     * update certificate
61
     *
62
     * @param string $sniOrId
63
     * @param \Unikorp\KongAdminApi\Document\CertificateDocument $document
64
     *
65
     * @return \Psr\Http\Message\ResponseInterface
66
     */
67 1
    public function updateCertificate(string $sniOrId, Document $document): ResponseInterface
68
    {
69 1
        return $this->patch(sprintf('/certificates/%1$s', $sniOrId), $document);
70
    }
71
72
    /**
73
     * update or create certificate
74
     *
75
     * @param \Unikorp\KongAdminApi\Document\CertificateDocument $document
76
     *
77
     * @return \Psr\Http\Message\ResponseInterface
78
     */
79 2
    public function updateOrCreateCertificate(Document $document): ResponseInterface
80
    {
81 2
        return $this->put('/certificates/', $document);
82
    }
83
84
    /**
85
     * delete certificate
86
     *
87
     * @param string $sniOrId
88
     *
89
     * @return \Psr\Http\Message\ResponseInterface
90
     */
91 1
    public function deleteCertificate(string $sniOrId): ResponseInterface
92
    {
93 1
        return $this->delete(sprintf('/certificates/%1$s', $sniOrId));
94
    }
95
}
96