ChangeEmailNotification   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 78.56%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 65
ccs 11
cts 14
cp 0.7856
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A via() 0 3 1
A toMail() 0 10 2
A toMailUsing() 0 3 1
1
<?php
2
3
namespace  Devpri\Tinre\Notifications;
4
5
use Illuminate\Notifications\Messages\MailMessage;
6
use Illuminate\Notifications\Notification;
7
8
class ChangeEmailNotification extends Notification
9
{
10
    /**
11
     * The password reset token.
12
     *
13
     * @var string
14
     */
15
    public $token;
16
17
    /**
18
     * The callback that should be used to build the mail message.
19
     *
20
     * @var \Closure|null
21
     */
22
    public static $toMailCallback;
23
24
    /**
25
     * Create a notification instance.
26
     *
27
     * @param  string  $token
28
     * @return void
29
     */
30 1
    public function __construct($token)
31
    {
32 1
        $this->token = $token;
33 1
    }
34
35
    /**
36
     * Get the notification's channels.
37
     *
38
     * @param  mixed  $notifiable
39
     * @return array|string
40
     */
41 1
    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

41
    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...
42
    {
43 1
        return ['mail'];
44
    }
45
46
    /**
47
     * Build the mail representation of the notification.
48
     *
49
     * @param  mixed  $notifiable
50
     * @return \Illuminate\Notifications\Messages\MailMessage
51
     */
52 1
    public function toMail($notifiable)
53
    {
54 1
        if (static::$toMailCallback) {
55
            return call_user_func(static::$toMailCallback, $notifiable, $this->token);
56
        }
57
58 1
        return (new MailMessage)
59 1
            ->subject('Change your email')
60 1
            ->line('You are receiving this email because we received a email change request for your account.')
61 1
            ->action('Change Email', url(config('app.url').route('email.change', $this->token, false)));
62
    }
63
64
    /**
65
     * Set a callback that should be used when building the notification mail message.
66
     *
67
     * @param  \Closure  $callback
68
     * @return void
69
     */
70
    public static function toMailUsing($callback)
71
    {
72
        static::$toMailCallback = $callback;
73
    }
74
}
75