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.

FootballData   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 177
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 3
dl 0
loc 177
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A prepareResponse() 0 4 1
A getAreas() 0 6 1
A getArea() 0 6 1
A getCompetition() 0 6 1
A getCompetitions() 0 6 1
A getCompetitionTeams() 0 6 1
A getCompetitionStandings() 0 6 1
A getCompetitionMatches() 0 6 1
A getMatches() 0 6 1
A getMatch() 0 6 1
A getPlayer() 0 6 1
A getPlayerMatches() 0 6 1
A getTeam() 0 6 1
A getTeamMatches() 0 6 1
1
<?php
2
3
namespace Johnathan\FootballData;
4
5
use GuzzleHttp\Client;
6
use Psr\Http\Message\ResponseInterface;
7
8
class FootballData
9
{
10
    protected $client;
11
12
    /**
13
     * FootballData constructor.
14
     * @param string $authToken
15
     */
16
    public function __construct(string $authToken)
17
    {
18
        $this->client = new Client([
19
            'base_uri' => 'http://api.football-data.org/v2/',
20
            'headers' => [
21
                'X-Auth-Token' => $authToken,
22
            ],
23
        ]);
24
    }
25
26
    /**
27
     * @param ResponseInterface $request
28
     * @return mixed
29
     */
30
    private function prepareResponse(ResponseInterface $request)
31
    {
32
        return json_decode($request->getBody()->getContents());
33
    }
34
35
    // Areas
36
37
    /**
38
     * @return array
39
     */
40
    public function getAreas() : array
41
    {
42
        $request = $this->client->get('areas');
43
44
        return $this->prepareResponse($request)->areas;
45
    }
46
47
    /**
48
     * @param int $areaId
49
     * @return \stdClass
50
     */
51
    public function getArea(int $areaId) : \stdClass
52
    {
53
        $request = $this->client->get(sprintf('areas/%s', $areaId));
54
55
        return $this->prepareResponse($request);
56
    }
57
58
    // Competitions
59
60
    /**
61
     * @param int $competitionId
62
     * @return \stdClass
63
     */
64
    public function getCompetition(int $competitionId) : \stdClass
65
    {
66
        $request = $this->client->get(sprintf('competitions/%s', $competitionId));
67
68
        return $this->prepareResponse($request);
69
    }
70
71
    /**
72
     * @return array
73
     */
74
    public function getCompetitions() : array
75
    {
76
        $request = $this->client->get('competitions');
77
78
        return $this->prepareResponse($request)->competitions;
79
    }
80
81
    /**
82
     * @param int $competitionId
83
     * @return array
84
     */
85
    public function getCompetitionTeams(int  $competitionId) : array
86
    {
87
        $request = $this->client->get(sprintf('competitions/%s/teams', $competitionId));
88
89
        return $this->prepareResponse($request)->teams;
90
    }
91
92
    /**
93
     * @param int $competitionId
94
     * @return array
95
     */
96
    public function getCompetitionStandings(int $competitionId) : array
97
    {
98
        $request = $this->client->get(sprintf('competitions/%s/standings', $competitionId));
99
100
        return $this->prepareResponse($request)->standings;
101
    }
102
103
    /**
104
     * @param $competitionId
105
     * @return array
106
     */
107
    public function getCompetitionMatches($competitionId) : array
108
    {
109
        $request = $this->client->get(sprintf('competitions/%s/matches', $competitionId));
110
111
        return $this->prepareResponse($request)->matches;
112
    }
113
114
    // Matches
115
116
    /**
117
     * @return array
118
     */
119
    public function getMatches() : array
120
    {
121
        $request = $this->client->get('matches');
122
123
        return $this->prepareResponse($request)->matches;
124
    }
125
126
    /**
127
     * @param int $matchId
128
     * @return \stdClass
129
     */
130
    public function getMatch(int $matchId) : \stdClass
131
    {
132
        $request = $this->client->get(sprintf('matches/%s', $matchId));
133
134
        return $this->prepareResponse($request);
135
    }
136
137
    // Players
138
139
    /**
140
     * @param int $playerId
141
     * @return \stdClass
142
     */
143
    public function getPlayer(int $playerId) : \stdClass
144
    {
145
        $request = $this->client->get(sprintf('players/%s', $playerId));
146
147
        return $this->prepareResponse($request);
148
    }
149
150
    /**
151
     * @param int $playerId
152
     * @return array
153
     */
154
    public function getPlayerMatches(int $playerId) : array
155
    {
156
        $request = $this->client->get(sprintf('players/%s/matches', $playerId));
157
158
        return $this->prepareResponse($request)->matches;
159
    }
160
161
    // Teams
162
163
    /**
164
     * @param int $teamId
165
     * @return \stdClass
166
     */
167
    public function getTeam(int $teamId) : \stdClass
168
    {
169
        $request = $this->client->get(sprintf('teams/%s', $teamId));
170
171
        return $this->prepareResponse($request);
172
    }
173
174
    /**
175
     * @param int $teamId
176
     * @return mixed
177
     */
178
    public function getTeamMatches(int $teamId)
179
    {
180
        $request = $this->client->get(sprintf('teams/%s/matches', $teamId));
181
182
        return $this->prepareResponse($request)->matches;
183
    }
184
}
185