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 ( c42cfc...29c08b )
by Casper
04:31 queued 02:06
created

VersionControlClient   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 64
ccs 18
cts 21
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A versionControlIndex() 0 22 4
A markUpdateAsSeen() 0 14 1
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 VersionControlClient
11
 *
12
 * @package NStack\Clients
13
 * @author  Tiago Araujo <[email protected]>
14
 */
15
class VersionControlClient 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 1
        $path = $this->buildPath($this->path) . "?platform=" . $platform;
38 1
        if ($currentVersion) {
39
            $path = $path . '&current_version=' . $currentVersion;
40
        }
41 1
        if ($lastVersion) {
42
            $path = $path . '&last_version=' . $lastVersion;
43
        }
44 1
        if ($test) {
45
            $path = $path . '&test=' . $test;
46
        }
47
48 1
        $response = $this->client->get($path);
49 1
        $contents = $response->getBody()->getContents();
50 1
        $data = json_decode($contents, true);
51
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
78 1
        return new SeenUpdate($data['data']);
79
    }
80
}