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
Pull Request — master (#4)
by Choraimy
06:30
created

PushwooshException::apiError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace NotificationChannels\Pushwoosh;
4
5
use Illuminate\Support\Collection;
6
use RuntimeException;
7
use Throwable;
8
9
/**
10
 * Exception thrown following communication failure with the Pushwoosh API.
11
 */
12
class PushwooshException extends RuntimeException
13
{
14
    /**
15
     * Create a new exception for an API error.
16
     *
17
     * @param object $payload
18
     * @param \Throwable|null $previous
19
     * @return \NotificationChannels\Pushwoosh\PushwooshException
20
     */
21
    public static function apiError($payload, Throwable $previous = null)
22
    {
23
        return new static(sprintf('Pushwoosh API error: %s', $payload->status_message), 0, $previous);
24
    }
25
26
    /**
27
     * Create a new exception for failed transmission.
28
     *
29
     * @param \Throwable|null $previous
30
     * @return \NotificationChannels\Pushwoosh\PushwooshException
31
     */
32
    public static function failedTransmission(Throwable $previous = null)
33
    {
34
        return new static('Failed to create message(s)', 0, $previous);
35
    }
36
37
    /**
38
     * Create a new exception for unknown devices.
39
     *
40
     * @param object $payload
41
     * @param \Throwable|null $previous
42
     * @return \NotificationChannels\Pushwoosh\PushwooshException
43
     */
44
    public static function unknownDevices($payload, Throwable $previous = null)
45
    {
46
        $devices = Collection::make($payload->response->UnknownDevices)->reduce(function ($carry, $devices) {
47
            return array_merge((array)$carry, $devices);
48
        }, []);
49
50
        return new static(sprintf('Unknown device(s) mentioned: %s', implode(', ', $devices)), 0, $previous);
51
    }
52
}
53