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.
Passed
Push — master ( 556562...8743ff )
by Casper
07:04 queued 05:11
created

CollectionsClient   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 74
rs 10
ccs 18
cts 21
cp 0.8571
wmc 5

5 Methods

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