Passed
Push — master ( b4b8e8...3089dd )
by Arthur
26:17 queued 02:28
created

WebBroadcastChannel   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

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

1 Method

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