EventHandler   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 9
dl 0
loc 21
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A subscribe() 0 18 1
1
<?php
2
3
namespace App\Mail;
4
5
use Mail;
6
use Illuminate\Mail\Message;
7
use Illuminate\Support\Facades\Password;
8
use Illuminate\Contracts\Events\Dispatcher;
9
use App\Services\Auth\Back\Events\UserCreated as BackUserCreated;
10
use App\Services\Auth\Front\Events\UserRegistered as FrontUserRegistered;
11
use App\Services\Auth\Front\Events\UserCreatedThroughBack as FrontUserCreatedThroughBack;
12
13
class EventHandler
14
{
15
    public function subscribe(Dispatcher $events)
16
    {
17
        $events->listen(FrontUserRegistered::class, function (FrontUserRegistered $event) {
18
            Mail::send(new Welcome($event->user));
0 ignored issues
show
Documentation introduced by
new \App\Mail\Welcome($event->user) is of type object<App\Mail\Welcome>, but the function expects a string|array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
19
        });
20
21
        $events->listen(FrontUserCreatedThroughBack::class, function (FrontUserCreatedThroughBack $event) {
22
            Password::broker('front')->sendResetLink(['email' => $event->user->email], function (Message $message) {
23
                $message->subject('Welkom bij '.config('app.url'));
24
            });
25
        });
26
27
        $events->listen(BackUserCreated::class, function (BackUserCreated $event) {
28
            Password::broker('back')->sendResetLink(['email' => $event->user->email], function (Message $message) {
29
                $message->subject('Welkom bij '.config('app.url'));
30
            });
31
        });
32
    }
33
}
34