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   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 47.37%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 0
dl 0
loc 28
ccs 9
cts 19
cp 0.4737
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 20 8
A __toString() 0 4 1
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