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

LocalizeClient::indexLanguage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
ccs 8
cts 8
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NStack\Clients;
4
5
use NStack\Exceptions\FailedToParseException;
6
use NStack\Models\Language;
7
use NStack\Models\Resource;
8
9
/**
10
 * Class CountriesClient
11
 *
12
 * @package NStack\Clients
13
 * @author  Casper Rasmussen <[email protected]>
14
 */
15
class LocalizeClient extends NStackClient
16
{
17
    /** @var string */
18
    protected $path = 'content/localize';
19
20
    /**
21
     * indexResources
22
     *
23
     * @param string $platform
24
     * @return array
25
     * @throws \NStack\Exceptions\FailedToParseException
26
     * @author Casper Rasmussen <[email protected]>
27
     */
28 1
    public function indexResources(string $platform): array
29
    {
30 1
        $response = $this->client->get($this->buildPath($this->path . '/resources/platforms/' . $platform));
31
32 1
        $contents = $response->getBody()->getContents();
33
34 1
        $data = json_decode($contents, true);
35
36 1
        $array = [];
37 1
        foreach ($data['data'] as $object) {
38 1
            $array[] = new Resource($object);
39
        }
40
41 1
        return $array;
42
    }
43
44
    /**
45
     * showResource
46
     *
47
     * @param $url
48
     * @return array
49
     * @author Casper Rasmussen <[email protected]>
50
     */
51 1
    public function showResource($url): array
52
    {
53 1
        $response = $this->client->get($url);
54
55 1
        $contents = $response->getBody()->getContents();
56
57 1
        $data = json_decode($contents, true);
58
59 1
        return $data;
60
    }
61
62
    /**
63
     * indexLanguage
64
     *
65
     * @param string $platform
66
     * @return array
67
     * @throws \NStack\Exceptions\FailedToParseException
68
     * @author Casper Rasmussen <[email protected]>
69
     */
70 1
    public function indexLanguage(string $platform): array
71
    {
72 1
        $response = $this->client->get($this->buildPath($this->path . '/' . $platform . '/languages'));
73 1
        $contents = $response->getBody()->getContents();
74 1
        $data = json_decode($contents, true);
75
76 1
        $array = [];
77 1
        foreach ($data['data'] as $object) {
78 1
            $array[] = new Language($object);
79
        }
80
81 1
        return $array;
82
    }
83
84
    /**
85
     * bestFitLanguage
86
     *
87
     * @param string $platform
88
     * @return Language
89
     * @throws FailedToParseException
90
     */
91 1
    public function bestFitLanguage(string $platform): Language
92
    {
93 1
        $response = $this->client->get($this->buildPath($this->path . '/' . $platform . '/languages/best_fit'));
94 1
        $contents = $response->getBody()->getContents();
95 1
        $data = json_decode($contents, true);
96
97 1
        return new Language($data['data']);
98
    }
99
}