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.

Endpoint   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 141
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 141
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A setAccessToken() 0 5 1
A getAccessToken() 0 4 1
A getList() 0 7 1
A getById() 0 6 1
A getRecent() 0 5 1
B fetchResults() 0 26 2
buildListUrl() 0 1 ?
buildSpecificEntryUrl() 0 1 ?
buildRecentUrl() 0 1 ?
1
<?php
2
3
namespace Choccybiccy\HumanApi;
4
5
use Choccybiccy\HumanApi\Collection;
6
7
/**
8
 * Class Endpoint
9
 * @package Choccybiccy\HumanApi
10
 */
11
abstract class Endpoint extends Api
12
{
13
14
    /**
15
     * @var string
16
     */
17
    protected $type;
18
19
    /**
20
     * @var string
21
     */
22
    protected $plural;
23
24
    /**
25
     * @var string
26
     */
27
    protected $accessToken;
28
29
    /**
30
     * @var bool
31
     */
32
    protected $listReturnsArray = true;
33
34
    /**
35
     * Set access token
36
     *
37
     * @param string $accessToken Access token
38
     * @return $this
39
     */
40
    public function setAccessToken($accessToken)
41
    {
42
        $this->accessToken = $accessToken;
43
        return $this;
44
    }
45
46
    /**
47
     * Get access token
48
     *
49
     * @return string
50
     */
51
    public function getAccessToken()
52
    {
53
        return $this->accessToken;
54
    }
55
56
    /**
57
     * Get list of entries
58
     *
59
     * @param array $params
60
     * @return Collection
61
     */
62
    public function getList(array $params = array())
63
    {
64
65
        $url = $this->buildListUrl();
66
        return $this->fetchResults($url, $params);
67
68
    }
69
70
    /**
71
     * Get entry by ID
72
     *
73
     * @param int $id
74
     * @param array $params
75
     * @return Collection
76
     */
77
    public function getById($id, array $params = array())
78
    {
79
        $this->listReturnsArray = false;
80
        $url = $this->buildSpecificEntryUrl($id);
81
        return $this->fetchResults($url, $params);
82
    }
83
84
    /**
85
     * Get recent entry
86
     *
87
     * @param array $params
88
     * @return Collection
89
     */
90
    public function getRecent(array $params = array())
91
    {
92
        $url = $this->buildRecentUrl();
93
        return $this->fetchResults($url, $params);
94
    }
95
96
    /**
97
     * Fetch results
98
     *
99
     * @param string $url
100
     * @param array $params
101
     * @return Collection
102
     */
103
    protected function fetchResults($url, array $params = array())
104
    {
105
        /** @var \GuzzleHttp\Message\Response $response */
106
        $response = call_user_func_array(
107
            array($this, $this->method),
108
            array(
109
                $url,
110
                array(
111
                    "query" => array_merge(
112
                        array(
113
                        "access_token" => $this->accessToken,
114
                        ),
115
                        $params
116
                    )
117
                )
118
            )
119
        );
120
121
        $responseJson = json_decode($response->getBody(), true);
122
        if (!$this->listReturnsArray) {
123
            $responseJson = array($responseJson);
124
        }
125
126
        return $this->buildCollection($responseJson);
127
128
    }
129
130
    /**
131
     * Build a url that returns a list of entries
132
     *
133
     * @return string
134
     */
135
    abstract protected function buildListUrl();
136
137
    /**
138
     * Build a url that returns a specific entry
139
     *
140
     * @param int $id ID
141
     * @return string
142
     */
143
    abstract protected function buildSpecificEntryUrl($id);
144
145
    /**
146
     * Build a url that returns recent entry
147
     *
148
     * @return string
149
     */
150
    abstract protected function buildRecentUrl();
151
}
152