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.

AbstractRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A makeRequest() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Monobank\Request;
6
7
use GuzzleHttp\Client;
8
use GuzzleHttp\ClientInterface;
9
use GuzzleHttp\Exception\RequestException;
10
use GuzzleHttp\Psr7\Request;
11
use Monobank\Exception\Factory;
12
13
abstract class AbstractRequest
14
{
15
    /**
16
     * @var ClientInterface|Client
17
     */
18
    protected $client;
19
20
    public function __construct(Client $client)
21
    {
22
        $this->client = $client;
23
    }
24
25
    /**
26
     * @throws \Monobank\Exception\InvalidAccountException
27
     * @throws \Monobank\Exception\InternalErrorException
28
     * @throws \Monobank\Exception\MonobankException
29
     * @throws \Monobank\Exception\TooManyRequestsException
30
     * @throws \Monobank\Exception\UnknownTokenException
31
     */
32
    protected function makeRequest(Request $request): array
33
    {
34
        try {
35
            $response = $this->client->send($request);
36
        } catch (RequestException $exception) {
37
            throw Factory::createFromResponse($exception->getResponse());
38
        }
39
40
        return json_decode($response->getBody()->getContents(), true);
41
    }
42
}
43