Passed
Push — master ( 536ce7...e09305 )
by Thomas
07:57
created

UpdateUsername::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Listeners;
4
5
use App\Events\StudentUpdated;
6
use App\Events\TeacherUpdated;
7
use App\Events\UserUpdated;
8
use App\Models\User;
9
10
class UpdateUsername
11
{
12
    public function handle(TeacherUpdated|StudentUpdated|UserUpdated $event) {
13
        if (User::whereUsername($event->user->email)->count() === 0) {
14
            $event->user->update(['username' => $event->user->email]);
15
        }
16
    }
17
}
18