Passed
Push — master ( 4b0d05...471523 )
by Arthur
103:49 queued 98:11
created

WebBroadcastChannel::send()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.1406

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 2
nop 2
dl 0
loc 14
ccs 6
cts 8
cp 0.75
crap 3.1406
rs 10
c 0
b 0
f 0
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 31
    public function send($notifiable, Notification $notification)
27
    {
28 31
        $message = $this->getData($notifiable, $notification);
29
30 31
        $event = new WebNotificationEvent(
31 31
            $notifiable, $notification, is_array($message) ? $message : $message->data
32
        );
33
34 31
        if ($message instanceof BroadcastMessage) {
35
            $event->onConnection($message->connection)
36
                ->onQueue($message->queue);
37
        }
38
39 31
        return $this->events->dispatch($event);
40
    }
41
}
42