Completed
Pull Request — master (#17)
by Fèvre
04:46 queued 02:18
created

ResetPasswordNotification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Xetaravel\Notifications;
3
4
use Illuminate\Bus\Queueable;
5
use Illuminate\Contracts\Queue\ShouldQueue;
6
use Illuminate\Notifications\Notification;
7
use Illuminate\Notifications\Messages\MailMessage;
8
9
class ResetPasswordNotification extends Notification implements ShouldQueue
10
{
11
    use Queueable;
12
13
    /**
14
     * The password reset token.
15
     *
16
     * @var string
17
     */
18
    public $token;
19
20
    /**
21
     * Create a notification instance.
22
     *
23
     * @param  string  $token
24
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
25
     */
26
    public function __construct($token)
27
    {
28
        $this->token = $token;
29
    }
30
31
    /**
32
     * Get the notification's channels.
33
     *
34
     * @param  mixed  $notifiable
35
     * @return array|string
36
     */
37
    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...
38
    {
39
        return ['mail'];
40
    }
41
42
    /**
43
     * Build the mail representation of the notification.
44
     *
45
     * @param mixed $notifiable
46
     *
47
     * @return \Illuminate\Notifications\Messages\MailMessage
48
     */
49
    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...
50
    {
51
        return (new MailMessage)
52
            ->line('You are receiving this email because we received a password reset request for your account.')
53
            ->line('If you did not request a password reset, no further action is required.')
54
            ->action('Reset Password', url(config('app.url') . route('users.auth.password.reset', $this->token, false)))
0 ignored issues
show
Documentation introduced by
$this->token is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Bug introduced by
It seems like url(config('app.url') . ..., $this->token, false)) targeting url() can also be of type object<Illuminate\Contracts\Routing\UrlGenerator>; 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...
55
            ->level('primary')
56
            ->subject('Reset Password - ' . config('app.name'));
57
    }
58
}
59