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 ( a2e66e...35ccb4 )
by
unknown
04:19 queued 01:40
created

serviceRespondedWithAnHttpError()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 5
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
3
namespace NotificationChannels\Discord\Exceptions;
4
5
use Exception;
6
use Illuminate\Support\Arr;
7
use Psr\Http\Message\ResponseInterface;
8
9
class CouldNotSendNotification extends Exception
10
{
11
    /**
12
     * @param  \Psr\Http\Message\ResponseInterface  $response
13
     * @return static
14
     */
15
    public static function serviceRespondedWithAnHttpError(ResponseInterface $response)
16
    {
17
        $message = "Discord responded with an HTTP error: {$response->getStatusCode()}";
18
19
        if ($error = Arr::get(json_decode($response->getBody(), true), 'message')) {
20
            $message .= ": $error";
21
        }
22
23
        return new static($message);
24
    }
25
26
    /**
27
     * @param  array  $response
28
     * @return static
29
     */
30
    public static function serviceRespondedWithAnApiError($response)
31
    {
32
        return new static("Discord responded with an API error: {$response['code']}: {$response['message']}");
33
    }
34
35
    /**
36
     * @param  \Exception  $exception
37
     * @return static
38
     */
39 2
    public static function serviceCommunicationError(Exception $exception)
40
    {
41 2
        return new static("Communication with Discord failed: {$exception->getCode()}: {$exception->getMessage()}");
42
    }
43
}
44