Test Failed
Push — master ( 7405ac...f937f1 )
by Burak
05:02
created

NotificationListener   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 38
ccs 0
cts 16
cp 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getListeners() 0 4 1
A render() 0 3 1
A mount() 0 4 1
A getCountProperty() 0 4 1
A showNewNotificationBadge() 0 5 1
1
<?php
2
3
namespace App\Http\Livewire;
4
5
use Livewire\Component;
6
7
class NotificationListener extends Component
8
{
9
    public bool $showNewNotificationBadge = false;
10
11
    public int $count = 88;
12
13
    public $user;
14
15
    // Computed Property
16
    public function getCountProperty()
17
    {
18
        dump('getCountProperty()');
19
        return 999; //$this->user->unreadNotifications()->count();
20
    }
21
22
    public function mount($user)
23
    {
24
        dump('mount:$user');
25
        $this->user = $user;
26
    }
27
28
    public function getListeners()
29
    {
30
        return [ // @todo {$this->user->id}
31
            "echo-private:App.Models.User.3dd6a60f-8c5d-49f8-b723-514ba4a941d6,BroadcastNotificationCreated" => 'showNewNotificationBadge',
32
        ];
33
    }
34
35
    public function showNewNotificationBadge()
36
    {
37
        dump('showNewNotificationBadge()');
38
        $this->showNewNotificationBadge = true;
39
        $this->count = 999; //$this->user->unreadNotifications()->count();
40
    }
41
42
    public function render()
43
    {
44
        return view('livewire.notification-listener');
45
    }
46
}
47