ResetPassword   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 14
c 1
b 0
f 0
dl 0
loc 67
ccs 0
cts 23
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toMail() 0 12 2
A toMailUsing() 0 3 1
A via() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace MedianetDev\LaravelAuthApi\Http\Controllers\Traits\Notifications;
4
5
use Illuminate\Notifications\Messages\MailMessage;
6
use Illuminate\Notifications\Notification;
7
use Illuminate\Support\Facades\Lang;
8
9
class ResetPassword extends Notification
10
{
11
    /**
12
     * The password reset token.
13
     *
14
     * @var string
15
     */
16
    public $token;
17
18
    /**
19
     * The callback that should be used to build the mail message.
20
     *
21
     * @var \Closure|null
22
     */
23
    public static $toMailCallback;
24
25
    /**
26
     * Create a notification instance.
27
     *
28
     * @param  string  $token
29
     * @return void
30
     */
31
    public function __construct($token)
32
    {
33
        $this->token = $token;
34
    }
35
36
    /**
37
     * Get the notification's channels.
38
     *
39
     * @param  mixed  $notifiable
40
     * @return array|string
41
     */
42
    public function via($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

42
    public function via(/** @scrutinizer ignore-unused */ $notifiable)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
43
    {
44
        return ['mail'];
45
    }
46
47
    /**
48
     * Build the mail representation of the notification.
49
     *
50
     * @param  mixed  $notifiable
51
     * @return \Illuminate\Notifications\Messages\MailMessage
52
     */
53
    public function toMail($notifiable)
54
    {
55
        if (static::$toMailCallback) {
56
            return call_user_func(static::$toMailCallback, $notifiable, $this->token);
57
        }
58
59
        return (new MailMessage)
60
            ->subject(Lang::get('Reset Password Notification'))
61
            ->line(Lang::get('You are receiving this email because we received a password reset request for your account.'))
62
            ->action($this->token, '')
63
            ->line(Lang::get('This password reset link will expire in :count minutes.', ['count' => config('auth.passwords.'.config('auth.defaults.passwords').'.expire')]))
64
            ->line(Lang::get('If you did not request a password reset, no further action is required.'));
65
    }
66
67
    /**
68
     * Set a callback that should be used when building the notification mail message.
69
     *
70
     * @param  \Closure  $callback
71
     * @return void
72
     */
73
    public static function toMailUsing($callback)
74
    {
75
        static::$toMailCallback = $callback;
76
    }
77
}
78