EventHandler::subscribe()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 18
rs 9.4285
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