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.

PushwooshChannel   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 62
ccs 16
cts 16
cp 1
rs 10
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A parseMessage() 0 3 1
A send() 0 18 5
A __construct() 0 3 1
A parseRecipients() 0 3 1
1
<?php
2
3
namespace NotificationChannels\Pushwoosh;
4
5
use Illuminate\Notifications\Notification;
6
use Illuminate\Support\Arr;
7
8
class PushwooshChannel
9
{
10
    protected $pushwoosh;
11
12
    /**
13
     * Create a new Pushwoosh notification channel.
14
     *
15
     * @param \NotificationChannels\Pushwoosh\Pushwoosh $pushwoosh
16
     * @return void
17
     */
18 18
    public function __construct(Pushwoosh $pushwoosh)
19
    {
20 18
        $this->pushwoosh = $pushwoosh;
21 18
    }
22
23
    /**
24
     * Parse the message.
25
     *
26
     * @param mixed $message
27
     * @return \NotificationChannels\Pushwoosh\PushwooshMessage
28
     */
29 6
    protected function parseMessage($message)
30
    {
31 6
        return new PushwooshMessage((string)$message);
32
    }
33
34
    /**
35
     * Parse the recipient(s).
36
     *
37
     * @param mixed $recipients
38
     * @return \NotificationChannels\Pushwoosh\PushwooshRecipient
39
     */
40 6
    protected function parseRecipients($recipients)
41
    {
42 6
        return (new PushwooshRecipient)->device(...Arr::wrap($recipients));
43
    }
44
45
    /**
46
     * Send the given notification.
47
     *
48
     * @param \Illuminate\Notifications\RoutesNotifications $notifiable
49
     * @param \Illuminate\Notifications\Notification $notification
50
     * @return void
51
     */
52 18
    public function send($notifiable, Notification $notification)
53
    {
54 18
        $recipients = $notifiable->routeNotificationFor('pushwoosh', $notification);
55
56
        /** @noinspection PhpUndefinedMethodInspection */
57 18
        if (!$recipients || !$message = $notification->toPushwoosh($notifiable)) {
58 12
            return;
59
        }
60
61 6
        if (!$message instanceof PushwooshMessage) {
62 6
            $message = $this->parseMessage($message)->associate($notification);
63
        }
64
65 6
        if (!$recipients instanceof PushwooshRecipient) {
66 6
            $recipients = $this->parseRecipients($recipients);
67
        }
68
69 6
        $this->pushwoosh->send($message)->to($recipients);
70 6
    }
71
}
72