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.

CollectionsClient   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 86.36%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 79
ccs 19
cts 22
cp 0.8636
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteItem() 0 3 1
A createItem() 0 8 1
A updateItem() 0 9 1
A view() 0 6 1
A viewItem() 0 6 1
1
<?php
2
3
namespace NStack\Clients;
4
5
/**
6
 * Class CollectionsClient
7
 *
8
 * @package NStack\Clients
9
 * @author  Tiago Araujo <[email protected]>
10
 */
11
class CollectionsClient extends NStackClient
12
{
13
    /** @var string */
14
    protected $path = 'content/collections';
15
16
    /**
17
     * view
18
     *
19
     * @param int $collectionId
20
     * @return array
21
     */
22 1
    public function view(int $collectionId): array
23
    {
24 1
        $response = $this->client->get($this->buildPath($this->path . '/' . $collectionId));
25 1
        $contents = $response->getBody()->getContents();
26
27 1
        return json_decode($contents, true)['data'];
28
    }
29
30
    /**
31
     * createItem
32
     *
33
     * @param int   $collectionId
34
     * @param array $params
35
     * @return array
36
     */
37 1
    public function createItem(int $collectionId, array $params): array
38
    {
39 1
        $response = $this->client->post($this->buildPath($this->path . '/' . $collectionId . '/items'), [
40 1
            'form_params' => $params,
41
        ]);
42 1
        $contents = $response->getBody()->getContents();
43
44 1
        return json_decode($contents, true)['data'];
45
    }
46
47
    /**
48
     * deleteItem
49
     *
50
     * @param int $collectionId
51
     * @param int $itemId
52
     */
53
    public function deleteItem(int $collectionId, int $itemId)
54
    {
55
        $this->client->delete($this->buildPath($this->path . '/' . $collectionId . '/items/' . $itemId));
56
    }
57
58
    /**
59
     * updateItem
60
     *
61
     * @param int   $collectionId
62
     * @param int   $itemId
63
     * @param array $params
64
     * @return array
65
     */
66 1
    public function updateItem(int $collectionId, int $itemId, array $params): array
67
    {
68 1
        $response = $this->client->post($this->buildPath($this->path . '/' . $collectionId . '/items/' . $itemId .
69 1
                                                         '/update'), [
70 1
            'form_params' => $params,
71
        ]);
72 1
        $contents = $response->getBody()->getContents();
73
74 1
        return json_decode($contents, true)['data'];
75
    }
76
77
    /**
78
     * viewItem
79
     *
80
     * @param int $collectionId
81
     * @param int $itemId
82
     * @return array
83
     */
84 1
    public function viewItem(int $collectionId, int $itemId): array
85
    {
86 1
        $response = $this->client->get($this->buildPath($this->path . '/' . $collectionId . '/items/' . $itemId));
87 1
        $contents = $response->getBody()->getContents();
88
89 1
        return json_decode($contents, true)['data'];
90
    }
91
}