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 (#2)
by VEBER
01:56
created

AbstractNode   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
lcom 1
cbo 3
dl 0
loc 94
ccs 17
cts 17
cp 1
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 4 1
A post() 0 6 2
A put() 0 6 2
A patch() 0 6 2
A delete() 0 6 2
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;
13
14
/**
15
 * abstract node
16
 *
17
 * @author VEBER Arnaud <https://github.com/VEBERArnaud>
18
 */
19
abstract class AbstractNode implements NodeInterface
20
{
21
    const JSON_CONTENT_TYPE = [
22
        'Content-Type' => 'application/json',
23
    ];
24
25
    /**
26
     * client
27
     * @var \Unikorp\KongAdminApi\Client $client
28
     */
29
    private $client = null;
30
31
    /**
32
     * Constructor
33
     *
34
     * @param \Unikorp\KongAdminApi\Client $client
35
     */
36 5
    public function __construct(Client $client)
37
    {
38 5
        $this->client = $client;
39 5
    }
40
41
    /**
42
     * get
43
     *
44
     * @param string $endpoint
45
     *
46
     * @return \Psr\Http\Message\ResponseInterface
47
     */
48 12
    protected function get($endpoint)
49
    {
50 12
        return $this->client->getHttpClient()->get($endpoint);
51
    }
52
53
    /**
54
     * post
55
     *
56
     * @param string $endpoint
57
     * @param DocumentInterface $document
58
     *
59
     * @return \Psr\Http\Message\ResponseInterface
60
     */
61 3
    protected function post($endpoint, DocumentInterface $document = null)
62
    {
63 3
        $body = (!is_null($document)) ? $document->toJson() : '[]';
64
65 3
        return $this->client->getHttpClient()->post($endpoint, self::JSON_CONTENT_TYPE, $body);
66
    }
67
68
    /**
69
     * put
70
     *
71
     * @param string $endpoint
72
     * @param DocumentInterface $document
73
     *
74
     * @return \Psr\Http\Message\ResponseInterface
75
     */
76 3
    protected function put($endpoint, DocumentInterface $document = null)
77
    {
78 3
        $body = (!is_null($document)) ? $document->toJson() : '[]';
79
80 3
        return $this->client->getHttpClient()->put($endpoint, self::JSON_CONTENT_TYPE, $body);
81
    }
82
83
    /**
84
     * patch
85
     *
86
     * @param string $endpoint
87
     * @param DocumentInterface $document
88
     *
89
     * @return \Psr\Http\Message\ResponseInterface
90
     */
91 3
    protected function patch($endpoint, DocumentInterface $document = null)
92
    {
93 3
        $body = (!is_null($document)) ? $document->toJson() : '[]';
94
95 3
        return $this->client->getHttpClient()->patch($endpoint, self::JSON_CONTENT_TYPE, $body);
96
    }
97
98
    /**
99
     * delete
100
     *
101
     * @param string $endpoint
102
     * @param DocumentInterface $document
103
     *
104
     * @return \Psr\Http\Message\ResponseInterface
105
     */
106 4
    protected function delete($endpoint, DocumentInterface $document = null)
107
    {
108 4
        $body = (!is_null($document)) ? $document->toJson() : '[]';
109
110 4
        return $this->client->getHttpClient()->delete($endpoint, self::JSON_CONTENT_TYPE, $body);
111
    }
112
}
113