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.

ApiException::__construct()   B
last analyzed

Complexity

Conditions 8
Paths 7

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 14.6701

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 9
cts 17
cp 0.5294
rs 8.4444
c 0
b 0
f 0
cc 8
nc 7
nop 2
crap 14.6701
1
<?php
2
3
namespace wlbrough\clearbit\Exceptions;
4
5
use Throwable;
6
7
class ApiException extends \Exception
8
{
9 12
    public function __construct($code, Throwable $previous = null)
10
    {
11 12
        if ($code === 400) {
12
            $message = "Bad Request";
13 12
        } elseif ($code === 401) {
14
            $message = "Your API key is invalid";
15 12
        } elseif ($code === 402) {
16
            $message = "Over plan quota on this endpoint";
17 12
        } elseif ($code === 404) {
18 12
            $message = "The resource does not exist";
19 8
        } elseif ($code === 422) {
20
            $message = "A validation error occurred";
21
        } elseif ($code >= 500 && code < 600) {
22
            $message = "An error occurred with our API";
23
        } else {
24
            $message = "Unknown error";
25
        }
26
27 12
        parent::__construct($message, $code, $previous);
28 12
    }
29
30
    public function __toString()
31
    {
32
        return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
33
    }
34
}
35