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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 39
ccs 0
cts 9
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A failedTransmission() 0 3 1
A apiError() 0 3 1
A unknownDevices() 0 7 1
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