Passed
Push — master ( e5b31a...cf340d )
by Arthur
04:48
created

WebNotificationChannel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 0 14 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 21:39
7
 */
8
9
namespace Foundation\Channels;
10
11
12
use Foundation\Events\WebNotificationCreatedEvent;
13
use Illuminate\Notifications\Channels\BroadcastChannel;
14
use Illuminate\Notifications\Notification;
15
use Illuminate\Notifications\Messages\BroadcastMessage;
16
17
class WebNotificationChannel extends BroadcastChannel
18
{
19
    /**
20
     * Send the given notification.
21
     *
22
     * @param  mixed  $notifiable
23
     * @param  \Illuminate\Notifications\Notification  $notification
24
     * @return array|null
25
     */
26
    public function send($notifiable, Notification $notification)
27
    {
28
        $message = $this->getData($notifiable, $notification);
29
30
        $event = new WebNotificationCreatedEvent(
31
            $notifiable, $notification, is_array($message) ? $message : $message->data
32
        );
33
34
        if ($message instanceof BroadcastMessage) {
35
            $event->onConnection($message->connection)
36
                ->onQueue($message->queue);
37
        }
38
39
        return $this->events->dispatch($event);
40
    }
41
}
42