SCBroadcaster::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace SocketCluster\Laravel;
3
4
use Illuminate\Contracts\Broadcasting\Broadcaster;
5
use SocketCluster\SocketCluster;
6
7
/**
8
 * @package SocketCluster\Laravel
9
 */
10
class SCBroadcaster implements Broadcaster
11
{
12
    /**
13
     * @var SocketCluster
14
     */
15
    protected $socketcluster;
16
17
    /**
18
     * Construct
19
     *
20
     * @param SocketCluster $socketcluster
21
     *
22
     * @param void
23
     */
24 3
    public function __construct(SocketCluster $socketcluster)
25
    {
26 3
        $this->socketcluster = $socketcluster;
27 3
    }
28
29
    /**
30
     * Broadcast
31
     *
32
     * @param array  $channels
33
     * @param string $event
34
     * @param array  $payload
35
     *
36
     * @return void
37
     */
38 1
    public function broadcast(array $channels, $event, array $payload = array())
39
    {
40 1
        foreach ($channels as $channel) {
41 1
            $this->socketcluster->publish($channel, $payload);
42 1
        }
43 1
    }
44
}
45