Passed
Push — main ( 4834b9...990a94 )
by Usama
03:51
created

CommentLikedNotification   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 15
c 1
b 0
f 1
dl 0
loc 51
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A toArray() 0 6 1
A via() 0 6 1
A toMail() 0 8 1
1
<?php
2
3
namespace Usamamuneerchaudhary\Commentify\Notifications;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Notifications\Messages\MailMessage;
8
use Illuminate\Notifications\Notification;
9
use Usamamuneerchaudhary\Commentify\Events\CommentLiked;
10
11
class CommentLikedNotification extends Notification implements ShouldQueue
12
{
13
    use Queueable;
14
15
    /**
16
     * Create a new notification instance.
17
     */
18
    public function __construct(
19
        public CommentLiked $event
20
    ) {
21
    }
22
23
    /**
24
     * Get the notification's delivery channels.
25
     *
26
     * @return array<int, string>
27
     */
28
    public function via(object $notifiable): array
0 ignored issues
show
Unused Code introduced by
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

28
    public function via(/** @scrutinizer ignore-unused */ object $notifiable): array

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...
29
    {
30
        $channels = config('commentify.notification_channels', ['database']);
31
32
        return array_filter($channels, function ($channel) {
33
            return in_array($channel, ['database', 'mail', 'broadcast']);
34
        });
35
    }
36
37
    /**
38
     * Get the mail representation of the notification.
39
     */
40
    public function toMail(object $notifiable): MailMessage
0 ignored issues
show
Unused Code introduced by
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

40
    public function toMail(/** @scrutinizer ignore-unused */ object $notifiable): MailMessage

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...
41
    {
42
        return (new MailMessage)
43
            ->subject(__('commentify::commentify.notifications.comment_liked_subject'))
44
            ->line(__('commentify::commentify.notifications.comment_liked_line'))
45
            ->action(
46
                __('commentify::commentify.notifications.view_comment'),
47
                url('/comments/' . $this->event->comment->id)
48
            );
49
    }
50
51
    /**
52
     * Get the array representation of the notification.
53
     *
54
     * @return array<string, mixed>
55
     */
56
    public function toArray(object $notifiable): array
0 ignored issues
show
Unused Code introduced by
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

56
    public function toArray(/** @scrutinizer ignore-unused */ object $notifiable): array

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...
57
    {
58
        return [
59
            'comment_id' => $this->event->comment->id,
60
            'user_id' => $this->event->userId,
61
            'message' => __('commentify::commentify.notifications.comment_liked_message'),
62
        ];
63
    }
64
}
65
66