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
Branch master (37a03c)
by Casper
02:30
created

LanguagesClient::index()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 18
rs 9.9332
ccs 11
cts 11
cp 1
crap 2
1
<?php
2
3
namespace NStack\Clients;
4
5
use NStack\Exceptions\FailedToParseException;
6
use NStack\Models\Language;
7
8
/**
9
 * Class LanguagesClient
10
 *
11
 * @package NStack\Clients
12
 * @author  Tiago Araujo <[email protected]>
13
 */
14
class LanguagesClient extends NStackClient
15
{
16
    /** @var string */
17
    protected $path = 'geographic/languages';
18
19
    /**
20
     * index
21
     *
22
     * @param int $page
23
     * @param int $limit
24
     * @return array
25
     * @throws FailedToParseException
26
     */
27 1
    public function index($page = 1, $limit = 500): array
28
    {
29 1
        $response = $this->client->get(
30 1
            $this->buildPath($this->path)
31 1
            . '/?page=' . $page
32 1
            . '&limit=' . $limit
33
        );
34
35 1
        $contents = $response->getBody()->getContents();
36
37 1
        $data = json_decode($contents, true);
38
39 1
        $array = [];
40 1
        foreach ($data['data'] as $object) {
41 1
            $array[] = new Language($object);
42
        }
43
44 1
        return $array;
45
    }
46
47
    /**
48
     * search
49
     *
50
     * @param String $term
51
     * @param int $page
52
     * @param int $limit
53
     * @return array
54
     * @throws FailedToParseException
55
     */
56 1
    public function search(String $term, $page = 1, $limit = 500): array
57
    {
58 1
        $response = $this->client->get($this->buildPath(
59 1
            $this->path
60 1
            . '/?search=' . $term
61 1
            . '&page=' . $page
62 1
            . '&limit=' . $limit
63
        ));
64
65 1
        $contents = $response->getBody()->getContents();
66
67 1
        $data = json_decode($contents, true);
68
69 1
        $array = [];
70 1
        foreach ($data['data'] as $object) {
71 1
            $array[] = new Language($object);
72
        }
73
74 1
        return $array;
75
    }
76
}