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.
Completed
Push — master ( 6cd6f9...73cd98 )
by Andreas
05:11
created

HttpExceptionHandler::getResponseMessage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaignApi\Client;
7
8
use CommerceLeague\ActiveCampaignApi\Exception\BadRequestHttpException;
9
use CommerceLeague\ActiveCampaignApi\Exception\ClientErrorHttpException;
10
use CommerceLeague\ActiveCampaignApi\Exception\NotFoundHttpException;
11
use CommerceLeague\ActiveCampaignApi\Exception\RedirectionHttpException;
12
use CommerceLeague\ActiveCampaignApi\Exception\ServerErrorHttpException;
13
use CommerceLeague\ActiveCampaignApi\Exception\UnauthorizedHttpException;
14
use CommerceLeague\ActiveCampaignApi\Exception\UnprocessableEntityHttpException;
15
use Psr\Http\Message\RequestInterface;
16
use Psr\Http\Message\ResponseInterface;
17
18
/**
19
 * Class HttpExceptionHandler
20
 */
21
class HttpExceptionHandler
22
{
23
    /**
24
     * @param RequestInterface $request
25
     * @param ResponseInterface $response
26
     * @return ResponseInterface
27
     */
28
    public function transformResponseToException(
29
        RequestInterface $request,
30
        ResponseInterface $response
31
    ): ResponseInterface {
32
        if ($response->getStatusCode() >= 300 && $response->getStatusCode() < 400) {
33
            throw new RedirectionHttpException($response->getReasonPhrase(), $request, $response);
34
        }
35
36
        if ($response->getStatusCode() === 400) {
37
            throw new BadRequestHttpException($response->getReasonPhrase(), $request, $response);
38
        }
39
40
        if ($response->getStatusCode() === 401) {
41
            throw new UnauthorizedHttpException($response->getReasonPhrase(), $request, $response);
42
        }
43
44
        if ($response->getStatusCode() === 404) {
45
            throw new NotFoundHttpException($response->getReasonPhrase(), $request, $response);
46
        }
47
48
        if ($response->getStatusCode() === 422) {
49
            throw new UnprocessableEntityHttpException($response->getReasonPhrase(), $request, $response);
50
        }
51
52
        if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
53
            throw new ClientErrorHttpException($response->getReasonPhrase(), $request, $response);
54
        }
55
56
        if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
57
            throw new ServerErrorHttpException($response->getReasonPhrase(), $request, $response);
58
        }
59
60
        return $response;
61
    }
62
}
63