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 ( 074ccd...27fc50 )
by Cody
03:21 queued 17s
created

serviceCommunicationError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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
     *
14
     * @return static
15
     */
16 1
    public static function serviceRespondedWithAnHttpError(ResponseInterface $response)
17
    {
18 1
        $message = "Discord responded with an HTTP error: {$response->getStatusCode()}";
19
20 1
        if ($error = Arr::get(json_decode($response->getBody(), true), 'message')) {
21 1
            $message .= ": $error";
22 1
        }
23
24 1
        return new static($message);
25
    }
26
27
    /**
28
     * @param array $response
29
     *
30
     * @return static
31
     */
32 1
    public static function serviceRespondedWithAnApiError(array $response)
33
    {
34 1
        return new static("Discord responded with an API error: {$response['code']}: {$response['message']}");
35
    }
36
37
    /**
38
     * @param \Exception $exception
39
     *
40
     * @return static
41
     */
42 2
    public static function serviceCommunicationError(Exception $exception)
43
    {
44 2
        return new static("Communication with Discord failed: {$exception->getCode()}: {$exception->getMessage()}");
45
    }
46
}
47