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.
Failed Conditions
Push — master ( 550dab...bc8237 )
by Casper
03:45 queued 02:01
created

NotifyClient::markUpdateAsSeen()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 13
ccs 9
cts 9
cp 1
crap 1
rs 9.9666
1
<?php
2
3
namespace NStack\Clients;
4
5
use NStack\Exceptions\FailedToParseException;
6
use NStack\Models\SeenUpdate;
7
use NStack\Models\VersionControlUpdate;
8
9
/**
10
 * Class NotifyClient
11
 *
12
 * @package NStack\Clients
13
 * @author Tiago Araujo <[email protected]>
14
 */
15
class NotifyClient extends NStackClient
16
{
17
    /** @var string */
18
    protected $path = 'notify/updates';
19
20
    /**
21
     * versionControlIndex
22
     *
23
     * @param String $platform
24
     * @param String|null $currentVersion
25
     * @param String|null $lastVersion
26
     * @param String|null $test
27
     * @return VersionControlUpdate
28
     * @throws FailedToParseException
29
     * @author Tiago Araujo <[email protected]>
30
     */
31 1
    public function versionControlIndex(
32
        String $platform,
33
        String $currentVersion = null,
34
        String $lastVersion = null,
35
        String $test = null
36
    ): VersionControlUpdate
37
    {
38 1
        $path = $this->buildPath($this->path) . "?platform=" . $platform;
39 1
        if ($currentVersion) {
40
            $path = $path . '&current_version=' . $currentVersion;
41
        }
42 1
        if ($lastVersion) {
43
            $path = $path . '&last_version=' . $lastVersion;
44
        }
45 1
        if ($test) {
46
            $path = $path . '&test=' . $test;
47
        }
48
49 1
        $response = $this->client->get($path);
50 1
        $contents = $response->getBody()->getContents();
51 1
        $data = json_decode($contents, true);
52 1
        return new VersionControlUpdate($data);
53
    }
54
55
    /**
56
     * markUpdateAsSeen
57
     *
58
     * @param String $guid
59
     * @param int $updateId
60
     * @param String $answer
61
     * @param String $type
62
     * @return SeenUpdate
63
     * @throws FailedToParseException
64
     */
65 1
    public function markUpdateAsSeen(String $guid, int $updateId, String $answer, String $type)
66
    {
67 1
        $response = $this->client->post($this->buildPath($this->path), [
68
            'form_params' => [
69 1
                'guid'      => $guid,
70 1
                'update_id' => $updateId,
71 1
                'answer'    => $answer,
72 1
                'type'      => $type,
73
            ]
74
        ]);
75 1
        $contents = $response->getBody()->getContents();
76 1
        $data = json_decode($contents, true);
77 1
        return new SeenUpdate($data['data']);
78
    }
79
80
}