Completed
Push — develop ( d40569...b3dafd )
by Abdelrahman
05:01
created

ContactCreated::broadcastAs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Contacts\Events;
6
7
use Rinvex\Contacts\Models\Contact;
8
use Illuminate\Broadcasting\Channel;
9
use Illuminate\Queue\SerializesModels;
10
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
11
12
class ContactCreated implements ShouldBroadcast
13
{
14
    use SerializesModels;
15
16
    public $contact;
17
18
    /**
19
     * Create a new event instance.
20
     *
21
     * @param \Rinvex\Contacts\Models\Contact $contact
22
     */
23
    public function __construct(Contact $contact)
24
    {
25
        $this->contact = $contact;
26
    }
27
28
    /**
29
     * Get the channels the event should broadcast on.
30
     *
31
     * @return \Illuminate\Broadcasting\Channel
32
     */
33
    public function broadcastOn()
34
    {
35
        return new Channel($this->formatChannelName());
36
    }
37
38
    /**
39
     * The event's broadcast name.
40
     *
41
     * @return string
42
     */
43
    public function broadcastAs()
44
    {
45
        return 'rinvex.contacts.created';
46
    }
47
48
    /**
49
     * Format channel name.
50
     *
51
     * @return string
52
     */
53
    protected function formatChannelName(): string
54
    {
55
        return 'rinvex.contacts.count';
56
    }
57
}
58