BadgeNotification::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Notifications;
6
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
use Illuminate\Notifications\Notification;
10
use Xetaravel\Models\Badge;
11
use Xetaravel\Models\User;
12
13
class BadgeNotification extends Notification implements ShouldQueue
14
{
15
    use Queueable;
16
17
    /**
18
     * The badge instance.
19
     *
20
     * @var Badge
21
     */
22
    public Badge $badge;
23
24
    /**
25
     * Create a new notification instance.
26
     *
27
     * @param Badge $badge
28
     */
29
    public function __construct(Badge $badge)
30
    {
31
        $this->badge = $badge;
32
    }
33
34
    /**
35
     * Get the notification's delivery channels.
36
     *
37
     * @param User $notifiable
38
     *
39
     * @return array
40
     */
41
    public function via(User $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

41
    public function via(/** @scrutinizer ignore-unused */ User $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...
42
    {
43
        return ['database'];
44
    }
45
46
    /**
47
     * Get the array representation of the notification.
48
     *
49
     * @param User $notifiable
50
     *
51
     * @return array
52
     */
53
    public function toDatabase(User $notifiable): array
54
    {
55
        return [
56
            'message' => "You have unlocked the badge <strong>{$this->badge->name}</strong> !",
57
            'icon' => $this->badge->icon,
58
            'color' => $this->badge->color,
59
            'type' => 'badge',
60
            'link' => $notifiable->show_url
0 ignored issues
show
Bug introduced by
The property show_url does not seem to exist on Xetaravel\Models\User.
Loading history...
61
        ];
62
    }
63
}
64