Completed
Pull Request — master (#19)
by
unknown
10:18
created

ConfirmEmail::confirmationUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BeyondCode\EmailConfirmation\Notifications;
4
5
use Carbon\Carbon;
6
use Illuminate\Bus\Queueable;
7
use Illuminate\Notifications\Notification;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Notifications\Messages\MailMessage;
10
use Illuminate\Support\Facades\URL;
11
12
class ConfirmEmail extends Notification implements ShouldQueue
13
{
14
    use Queueable;
15
16
    /**
17
     * Get the notification's delivery channels.
18
     *
19
     * @param  mixed  $notifiable
20
     * @return array
21
     */
22
    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...
23
    {
24
        return ['mail'];
25
    }
26
27
    /**
28
     * Get the mail representation of the notification.
29
     *
30
     * @param  mixed  $notifiable
31
     * @return \Illuminate\Notifications\Messages\MailMessage
32
     */
33
    public function toMail($notifiable)
34
    {
35
        return (new MailMessage)
36
            ->subject(__('confirmation::confirmation.confirmation_subject'))
0 ignored issues
show
Bug introduced by
It seems like __('confirmation::confir....confirmation_subject') targeting __() can also be of type array or null; however, Illuminate\Notifications...impleMessage::subject() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
37
            ->line(__('confirmation::confirmation.confirmation_subject_title'))
38
            ->line(__('confirmation::confirmation.confirmation_body'))
39
            ->action(__('confirmation::confirmation.confirmation_button'), $this->confirmationUrl($notifiable));
0 ignored issues
show
Bug introduced by
It seems like __('confirmation::confir...n.confirmation_button') targeting __() can also be of type array or null; however, Illuminate\Notifications...SimpleMessage::action() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
40
    }
41
42
    protected function confirmationUrl($notifiable)
43
    {
44
        return URL::temporarySignedRoute(
45
            "auth.confirm",
46
            now()->addMinutes(config('confirmation.timeout',60)),
47
            ['id' => $notifiable->getKey()]
48
        );
49
    }
50
}
51