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.

ServiceExceptionFactory::exception()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 19
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 9
c 1
b 0
f 0
nc 5
nop 0
dl 0
loc 19
rs 9.6111
1
<?php
2
3
namespace Honeybadger\Exceptions;
4
5
use Exception;
6
use Psr\Http\Message\ResponseInterface;
7
use Symfony\Component\HttpFoundation\Response;
8
9
class ServiceExceptionFactory
10
{
11
    /**
12
     * @var \Psr\Http\Message\ResponseInterface
13
     */
14
    protected $response;
15
16
    /**
17
     * @param  \Psr\Http\Message\ResponseInterface  $response
18
     */
19
    public function __construct(ResponseInterface $response)
20
    {
21
        $this->response = $response;
22
    }
23
24
    public function make(): Exception
25
    {
26
        return $this->exception();
27
    }
28
29
    /**
30
     * @return void
31
     *
32
     * @throws \Honeybadger\Exceptions\ServiceException
33
     */
34
    private function exception(): void
35
    {
36
        if ($this->response->getStatusCode() === Response::HTTP_FORBIDDEN) {
37
            throw ServiceException::invalidApiKey();
38
        }
39
40
        if ($this->response->getStatusCode() === Response::HTTP_UNPROCESSABLE_ENTITY) {
41
            throw ServiceException::invalidPayload();
42
        }
43
44
        if ($this->response->getStatusCode() === Response::HTTP_TOO_MANY_REQUESTS) {
45
            throw ServiceException::rateLimit();
46
        }
47
48
        if ($this->response->getStatusCode() === Response::HTTP_INTERNAL_SERVER_ERROR) {
49
            throw ServiceException::serverError();
50
        }
51
52
        throw ServiceException::generic();
53
    }
54
}
55