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::viewItem()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
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
}