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

LanguagesClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 61
rs 10
ccs 23
cts 23
cp 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A search() 0 19 2
A index() 0 18 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
}