ConfirmEmailNotification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Notifications;
12
13
use App\Models\User;
14
use Illuminate\Bus\Queueable;
15
use Illuminate\Notifications\Notification;
16
use Tymon\JWTAuth\Providers\JWT\JWTInterface;
17
use Illuminate\Notifications\Messages\MailMessage;
18
19
/**
20
 * Class ConfirmEmailNotification.
21
 */
22
class ConfirmEmailNotification extends Notification
23
{
24
    use Queueable;
25
26
    /**
27
     * @var User
28
     */
29
    private $user;
30
31
    /**
32
     * @var JWTInterface
33
     */
34
    private $jwt;
35
36
    /**
37
     * ConfirmEmailNotification constructor.
38
     *
39
     * @param User         $user
40
     * @param JWTInterface $jwt
41
     */
42
    public function __construct(User $user, JWTInterface $jwt)
43
    {
44
        $this->user = $user;
45
        $this->jwt = $jwt;
46
    }
47
48
    /**
49
     * Get the notification's delivery channels.
50
     */
51
    public function via($notifiable): array
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

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

Loading history...
52
    {
53
        return ['mail'];
54
    }
55
56
    /**
57
     * Get the mail representation of the notification.
58
     *
59
     * @param  mixed                                          $notifiable
60
     * @return \Illuminate\Notifications\Messages\MailMessage
61
     */
62
    public function toMail($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

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

Loading history...
63
    {
64
        $token = $this->jwt->encode($this->createToken());
65
66
        $action = route('confirmation.confirm', [
67
            'token' => $token,
68
        ]);
69
70
        return (new MailMessage)
71
            ->success()
72
            ->line('Подтвердите свой Email')
73
            ->action('Подтвердить', $action)
74
            ->line('Спасибо, что остаётесь с нами!');
75
    }
76
77
    /**
78
     * @return array
79
     */
80
    private function createToken(): array
81
    {
82
        return [
83
            'email' => $this->user->email,
84
        ];
85
    }
86
87
    /**
88
     * Get the array representation of the notification.
89
     *
90
     * @param  mixed $notifiable
91
     * @return array
92
     */
93
    public function toArray($notifiable)
0 ignored issues
show
Unused Code introduced by
The parameter $notifiable is not used and could be removed.

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

Loading history...
94
    {
95
        return [
96
            //
97
        ];
98
    }
99
}
100