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

UpdateUsername   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 3 2
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