Completed
Pull Request — master (#75)
by Alex
01:36
created

BroadcastsEvents::broadcastEventForAppToChannel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 5
1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\HttpApi\Controllers\Concerns;
4
5
trait BroadcastsEvents
6
{
7
    protected function broadcastEventForAppToChannel($appId, $channelName, $event, $data, $socketId = null): void
8
    {
9
        $channel = $this->channelManager->find($appId, $channelName);
0 ignored issues
show
Bug introduced by
The property channelManager does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
10
11
        optional($channel)->broadcastToEveryoneExcept([
12
            'channel' => $channelName,
13
            'event' => $event,
14
            'data' => $data,
15
        ], $socketId);
16
17
        DashboardLogger::apiMessage(
18
            $appId,
19
            $channelName,
20
            $event,
21
            $data
22
        );
23
24
        StatisticsLogger::apiMessage($appId);
25
    }
26
}
27