Test Failed
Push — master ( 7d3b62...53acba )
by Koen
07:55
created

PasswordReset::toMail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 14
ccs 0
cts 10
cp 0
crap 2
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Notifications\User;
6
7
use App\Models\User;
8
use Illuminate\Notifications\Messages\MailMessage;
9
use Illuminate\Notifications\Notification;
10
use Illuminate\Support\Facades\Lang;
11
use function App\Support\front_url;
12
use function config;
13
use function http_build_query;
14
15
final class PasswordReset extends Notification
16
{
17
    /**
18
     * The password reset token.
19
     *
20
     * @var string
21
     */
22
    public $token;
23
24
    /**
25
     * Create a notification instance.
26
     *
27
     * @param string $token
28
     * @return void
29
     */
30 2
    public function __construct(string $token)
31
    {
32 2
        $this->token = $token;
33 2
    }
34
35
    /**
36
     * Get the notification's delivery channels.
37
     *
38
     * @return array
39
     */
40 2
    public function via(): array
41
    {
42 2
        return ['mail'];
43
    }
44
45
    /**
46
     * Get the mail representation of the notification.
47
     *
48
     * @param User $user
49
     * @return \Illuminate\Notifications\Messages\MailMessage
50
     */
51
    public function toMail(User $user): MailMessage
52
    {
53
        $query = http_build_query([
54
            'email' => $user->getEmailForPasswordReset(),
55
        ]);
56
57
        $url = front_url('password/reset/' . $this->token . '?' . $query);
58
59
        return (new MailMessage())
60
            ->subject(Lang::getFromJson('Reset Password Notification'))
61
            ->line(Lang::getFromJson('You are receiving this email because we received a password reset request for your account.'))
62
            ->action(Lang::getFromJson('Reset Password'), $url)
63
            ->line(Lang::getFromJson('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.user-invitations.expire')]))
64
            ->line(Lang::getFromJson('If you did not request a password reset, no further action is required.'));
65
    }
66
}
67