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.
Passed
Pull Request — master (#57)
by TJ
03:15
created

ServiceExceptionFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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