MachineUpdatedEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
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: 19:31.
7
 */
8
9
namespace Modules\Machine\Events;
10
11
use Foundation\Abstracts\Events\Event;
12
use Illuminate\Broadcasting\PrivateChannel;
13
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
14
use Modules\Machine\Entities\Machine;
15
use Modules\Machine\Transformers\MachineTransformer;
16
17
class MachineUpdatedEvent extends Event implements ShouldBroadcast
18
{
19
    public $listeners = [];
20
21
    /**
22
     * @var Machine
23
     */
24
    public $machine;
25
26
    /**
27
     * UserRegisteredEvent constructor.
28
     *
29
     * @param $user
30
     */
31
    public function __construct(Machine $machine)
32
    {
33
        $this->machine = $machine;
34
    }
35
36
    public function broadcastOn()
37
    {
38
        return new PrivateChannel('user.'.$this->machine->user_id);
39
    }
40
41
    public function broadcastAs()
42
    {
43
        return 'machine.updated';
44
    }
45
46
    public function broadcastWith()
47
    {
48
        return MachineTransformer::resource($this->machine)->serialize();
49
    }
50
}
51