Passed
Pull Request — master (#7)
by Koen
04:19
created

VerifyUpdate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Notifications\User\Email;
6
7
use App\Auth\EmailDispensary;
8
use App\Models\User;
9
use App\SPA\UrlGenerator;
10
use Illuminate\Notifications\Messages\MailMessage;
11
use Illuminate\Notifications\Notification;
12
13
final class VerifyUpdate extends Notification
14
{
15
    public string $token;
16
17 3
    public function __construct(string $token)
18
    {
19 3
        $this->token = $token;
20 3
    }
21
22 2
    public function via(): array
23
    {
24 2
        return ['mail'];
25
    }
26
27 1
    public function toMail(User $user): MailMessage
28
    {
29 1
        $url = app(UrlGenerator::class)->to('profile/email/verify') . "#token={$this->token}&email={$user->getEmail()}";
30
31 1
        return (new MailMessage())
32 1
            ->subject('Email address update request')
33 1
            ->line('You are receiving this email because you\'ve requested to change your email address.')
34 1
            ->line('To verify this update click on the button below.')
35 1
            ->action('Verify email address', $url)
36 1
            ->line('This email will expire in ' . EmailDispensary::TTL / 60 . ' minutes.');
37
    }
38
}
39