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.

LanguagesClient::search()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 19
rs 9.9
ccs 12
cts 12
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
}