GeneralNotification::via()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Transmissor\Notifications;
4
5
use Illuminate\Notifications\Notification;
6
use Illuminate\Notifications\Messages\MailMessage;
7
8
class GeneralNotification extends Notification
9
{
10
    /**
11
     * General notification info
12
     *
13
     * @var string
14
     */
15
    public $info;
16
17
    /**
18
     * Create a notification instance.
19
     *
20
     * @param  string $token
0 ignored issues
show
Bug introduced by
There is no parameter named $token. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
21
     * @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...
22
     */
23
    public function __construct($info)
24
    {
25
        $this->info = $info;
26
    }
27
28
    /**
29
     * Get the notification's channels.
30
     *
31
     * @param  mixed $notifiable
32
     * @return array|string
33
     */
34
    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...
35
    {
36
        return [
37
            'mail'
38
        ];
39
    }
40
41
    /**
42
     * Build the mail representation of the notification.
43
     *
44
     * @param  mixed $notifiable
45
     * @return \Illuminate\Notifications\Messages\MailMessage
46
     */
47
    public function toMail($notifiable)
48
    {
49
        return (new MailMessage)
50
            ->line('Hey '.$notifiable->name)
51
            ->line('We have a notfiication for you.')
52
            ->line($this->info['title'])
53
            ->line($this->info['details'])
54
            ->action('Visit here for more info', url('/user/notifications'));
0 ignored issues
show
Bug introduced by
It seems like url('/user/notifications') 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
    }
56
}