Issues (48)

src/Notifications/AnnouncementNotification.php (5 issues)

1
<?php
2
3
namespace Adminetic\Announcement\Notifications;
4
5
use Adminetic\Announcement\Mail\AnnouncementMail;
6
use Adminetic\Announcement\Models\Admin\Announcement;
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Notifications\Notification;
9
10
class AnnouncementNotification extends Notification
11
{
12
    use Queueable;
13
14
    protected $announcement;
15
16
    /**
17
     * Create a new notification instance.
18
     *
19
     * @return void
20
     */
21
    public function __construct(Announcement $announcement)
22
    {
23
        $this->announcement = $announcement;
24
    }
25
26
    /**
27
     * Get the notification's delivery channels.
28
     *
29
     * @param  mixed  $notifiable
30
     * @return array
31
     */
32
    public function via($notifiable)
0 ignored issues
show
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

32
    public function via(/** @scrutinizer ignore-unused */ $notifiable)

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

Loading history...
33
    {
34
        return $this->announcement->mediums();
0 ignored issues
show
Are you sure the usage of $this->announcement->mediums() targeting Adminetic\Announcement\M...Announcement::mediums() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
35
    }
36
37
    /**
38
     * Get the mail representation of the notification.
39
     *
40
     * @param  mixed  $notifiable
41
     * @return \Illuminate\Notifications\Messages\MailMessage
42
     */
43
    public function toMail($notifiable)
44
    {
45
        return (new AnnouncementMail($this->announcement))
0 ignored issues
show
Bug Best Practice introduced by
The expression return new Adminetic\Ann...>to($notifiable->email) returns the type Adminetic\Announcement\Mail\AnnouncementMail which is incompatible with the documented return type Illuminate\Notifications\Messages\MailMessage.
Loading history...
46
            ->to($notifiable->email);
47
    }
48
49
    /**
50
     * Get the array representation of the notification.
51
     *
52
     * @param  mixed  $notifiable
53
     * @return array
54
     */
55
    public function toArray($notifiable)
0 ignored issues
show
The parameter $notifiable is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

55
    public function toArray(/** @scrutinizer ignore-unused */ $notifiable)

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

Loading history...
56
    {
57
        return [
58
            'model' => 'announcement',
59
            'id' => $this->announcement->id,
60
            'date_time' => $this->announcement->created_at->diffForHumans(),
0 ignored issues
show
The method diffForHumans() does not exist on DateTime. It seems like you code against a sub-type of DateTime such as Carbon\Carbon. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

60
            'date_time' => $this->announcement->created_at->/** @scrutinizer ignore-call */ diffForHumans(),
Loading history...
61
            'announcement_by' => $this->announcement->user->name ?? 'N/A',
62
            'announcement' => $this->announcement->body,
63
        ];
64
    }
65
}
66