SendActivationLinkViaEmail   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 2
1
<?php namespace App\Listeners\Users;
2
3
use App\Traits\Users\Activates;
4
use Illuminate\Mail\Message;
5
6
class SendActivationLinkViaEmail
7
{
8
    use Activates;
9
10 1
    public function handle($event) // Don't type-hint: this listener can be triggered by different events.
11
    {
12
        /** @var \App\Models\User $user */
13 1
        $user = $event->user;
14 1
        if (false === ($activation = $this->exists($user))) {
15 1
            $activation = $this->create($user);
16
        }
17 1
        $token = $activation->code;
18 1
        $view = config('auth.activations.view');
19 1
        app('mailer')->send($view, compact('user', 'token'), function (Message $m) use ($user, $token) {
20 1
            $m->to($user->email)->subject($this->getActivationEmailSubject());
0 ignored issues
show
Bug introduced by
It seems like $this->getActivationEmailSubject() targeting App\Traits\Users\Activat...ctivationEmailSubject() can also be of type object<Illuminate\Contra...Translation\Translator>; however, Illuminate\Mail\Message::subject() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
21 1
        });
22 1
    }
23
}
24