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.

CountriesClient::index()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 10
ccs 8
cts 8
cp 1
crap 2
1
<?php
2
3
namespace NStack\Clients;
4
5
use NStack\Models\Country;
6
7
/**
8
 * Class CountriesClient
9
 *
10
 * @package NStack\Clients
11
 * @author  Casper Rasmussen <[email protected]>
12
 */
13
class CountriesClient extends NStackClient
14
{
15
    /** @var string */
16
    protected $path = 'geographic/countries';
17
18
    /**
19
     * index
20
     *
21
     * @return array
22
     * @throws \NStack\Exceptions\FailedToParseException
23
     * @author Casper Rasmussen <[email protected]>
24
     */
25 1
    public function index(): array
26
    {
27 1
        $response = $this->client->get($this->buildPath($this->path));
28
29 1
        $contents = $response->getBody()->getContents();
30
31 1
        $data = json_decode($contents, true);
32
33 1
        $array = [];
34 1
        foreach ($data['data'] as $object) {
35 1
            $array[] = new Country($object);
36
        }
37
38 1
        return $array;
39
    }
40
41
    /**
42
     * show
43
     *
44
     * @param $id
45
     * @return \NStack\Models\Country
46
     * @throws \NStack\Exceptions\FailedToParseException
47
     * @author Casper Rasmussen <[email protected]>
48
     */
49 1
    public function show($id): Country
50
    {
51 1
        $response = $this->client->get($this->buildPath($this->path . '/' . $id));
52
53 1
        $contents = $response->getBody()->getContents();
54
55 1
        $data = json_decode($contents, true);
56
57 1
        return new Country($data['data']);
58
    }
59
}