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
02:01
created

Api::updateApi()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 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\Api;
13
14
use Unikorp\KongAdminApi\ApiAbstract;
15
use Unikorp\KongAdminApi\Client;
16
17
/**
18
 * api
19
 *
20
 * @author VEBER Arnaud <https://github.com/VEBERArnaud>
21
 */
22 View Code Duplication
class Api extends ApiAbstract
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...
23
{
24
    /**
25
     * add api
26
     *
27
     * @param array $params
28
     *
29
     * @return \Psr\Http\Message\ResponseInterface
30
     */
31
    public function addApi(array $params)
32
    {
33
        $headers = [
34
            'Content-Type' => 'application/json',
35
        ];
36
37
        $body = json_encode($params);
38
39
        return $this->post('/apis/', $headers, $body);
40
    }
41
42
    /**
43
     * retrieve api
44
     *
45
     * @param string $nameOrId
46
     *
47
     * @return \Psr\Http\Message\ResponseInterface
48
     */
49
    public function retrieveApi($nameOrId)
50
    {
51
        return $this->get(sprintf('/apis/%1$s', $nameOrId));
52
    }
53
54
    /**
55
     * list apis
56
     *
57
     * @return \Psr\Http\Message\ResponseInterface
58
     */
59
    public function listApis()
60
    {
61
        return $this->get('/apis/');
62
    }
63
64
    /**
65
     * update api
66
     *
67
     * @param string $nameOrId
68
     * @param array $params
69
     *
70
     * @return \Psr\Http\Message\ResponseInterface
71
     */
72
    public function updateApi($nameOrId, array $params)
73
    {
74
        $headers = [
75
            'Content-Type' => 'application/json',
76
        ];
77
78
        $body = json_encode($params);
79
80
        return $this->patch(sprintf('/apis/%1$s', $nameOrId), $headers, $body);
81
    }
82
83
    /**
84
     * update or create api
85
     *
86
     * @param array $params
87
     *
88
     * @return \Psr\Http\Message\ResponseInterface
89
     */
90
    public function updateOrCreateApi(array $params)
91
    {
92
        $headers = [
93
            'Content-Type' => 'application/json',
94
        ];
95
96
        $body = json_encode($params);
97
98
        return $this->put('/apis/', $headers, $body);
99
    }
100
101
    /**
102
     * delete api
103
     *
104
     * @param string $nameOrId
105
     *
106
     * @return \Psr\Http\Message\ResponseInterface
107
     */
108
    public function deleteApi($nameOrId)
109
    {
110
        return $this->delete(sprintf('/apis/%1$s', $nameOrId));
111
    }
112
}
113