Completed
Push — develop ( 5abd4c...dae2aa )
by Abdelrahman
09:07
created

ManagerEmailVerificationNotification::via()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Auth\Notifications;
6
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Notifications\Notification;
9
use Illuminate\Contracts\Queue\ShouldQueue;
10
use Illuminate\Notifications\Messages\MailMessage;
11
12
class ManagerEmailVerificationNotification extends Notification implements ShouldQueue
13
{
14
    use Queueable;
15
16
    /**
17
     * The email verification token.
18
     *
19
     * @var string
20
     */
21
    public $token;
22
23
    /**
24
     * The email verification expiration date.
25
     *
26
     * @var int
27
     */
28
    public $expiration;
29
30
    /**
31
     * Create a notification instance.
32
     *
33
     * @param string $token
34
     * @param string $expiration
35
     */
36
    public function __construct($token, $expiration)
37
    {
38
        $this->token = $token;
39
        $this->expiration = $expiration;
0 ignored issues
show
Documentation Bug introduced by
The property $expiration was declared of type integer, but $expiration is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
40
    }
41
42
    /**
43
     * Get the notification's channels.
44
     *
45
     * @param mixed $notifiable
46
     *
47
     * @return array|string
48
     */
49
    public function via($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...
50
    {
51
        return ['mail'];
52
    }
53
54
    /**
55
     * Build the mail representation of the notification.
56
     *
57
     * @param mixed $notifiable
58
     *
59
     * @return \Illuminate\Notifications\Messages\MailMessage
60
     */
61
    public function toMail($notifiable): MailMessage
62
    {
63
        $email = $notifiable->getEmailForVerification();
64
        $link = route('managerarea.verification.email.verify')."?email={$email}&expiration={$this->expiration}&token={$this->token}";
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
65
66
        return (new MailMessage())
67
            ->subject(trans('cortex/auth::emails.verification.email.subject'))
68
            ->line(trans('cortex/auth::emails.verification.email.intro', ['expire' => now()->createFromTimestamp($this->expiration)->diffForHumans()]))
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 151 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
69
            ->action(trans('cortex/auth::emails.verification.email.action'), $link)
70
            ->line(trans('cortex/auth::emails.verification.email.outro'));
71
    }
72
}
73