AddressSaved   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 59
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A broadcastOn() 0 4 1
A broadcastAs() 0 4 1
A formatChannelName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Addresses\Events;
6
7
use Illuminate\Broadcasting\Channel;
8
use Rinvex\Addresses\Models\Address;
9
use Illuminate\Queue\SerializesModels;
10
use Illuminate\Broadcasting\InteractsWithSockets;
11
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
12
13
class AddressSaved implements ShouldBroadcast
14
{
15
    use SerializesModels;
16
    use InteractsWithSockets;
17
18
    /**
19
     * The name of the queue on which to place the event.
20
     *
21
     * @var string
22
     */
23
    public $broadcastQueue = 'events';
24
25
    /**
26
     * The model instance passed to this event.
27
     *
28
     * @var \Rinvex\Addresses\Models\Address
29
     */
30
    public $address;
31
32
    /**
33
     * Create a new event instance.
34
     *
35
     * @param \Rinvex\Addresses\Models\Address $address
36
     */
37
    public function __construct(Address $address)
38
    {
39
        $this->address = $address;
40
    }
41
42
    /**
43
     * Get the channels the event should broadcast on.
44
     *
45
     * @return \Illuminate\Broadcasting\Channel
46
     */
47
    public function broadcastOn()
48
    {
49
        return new Channel($this->formatChannelName());
50
    }
51
52
    /**
53
     * The event's broadcast name.
54
     *
55
     * @return string
56
     */
57
    public function broadcastAs()
58
    {
59
        return 'rinvex.addresses.saved';
60
    }
61
62
    /**
63
     * Format channel name.
64
     *
65
     * @return string
66
     */
67
    protected function formatChannelName(): string
68
    {
69
        return 'rinvex.addresses.list';
70
    }
71
}
72