Passed
Push — master ( 4c3e72...46eb59 )
by Arthur
10:39
created

WebBroadcastChannel::send()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 2
nop 2
dl 0
loc 14
ccs 0
cts 11
cp 0
crap 12
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 Foundation\Events\WebNotificationCreatedEvent;
0 ignored issues
show
Bug introduced by
The type Foundation\Events\WebNotificationCreatedEvent was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Illuminate\Notifications\Channels\BroadcastChannel;
13
use Illuminate\Notifications\Messages\BroadcastMessage;
14
use Illuminate\Notifications\Notification;
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
    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