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 ( d9c91f...37a03c )
by Casper
01:54 queued 11s
created

LanguagesClient::search()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
dl 20
loc 20
ccs 12
cts 12
cp 1
rs 9.6
c 0
b 0
f 0
cc 2
nc 2
nop 3
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 View Code Duplication
    public function index($page = 1, $limit = 500): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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 View Code Duplication
    public function search(String $term, $page = 1, $limit = 500): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
}