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

PasswordReset   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 12
c 2
b 0
f 0
dl 0
loc 50
ccs 5
cts 15
cp 0.3333
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A via() 0 3 1
A toMail() 0 14 1
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