Passed
Push — main ( e2b24b...b1209d )
by PRATIK
04:16
created

SlackAnnouncementNotification::toSlack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Adminetic\Announcement\Notifications;
4
5
use Illuminate\Bus\Queueable;
6
use League\HTMLToMarkdown\HtmlConverter;
7
use Illuminate\Notifications\Notification;
8
use Illuminate\Notifications\Messages\SlackMessage;
9
use Adminetic\Announcement\Models\Admin\Announcement;
10
11
class SlackAnnouncementNotification extends Notification
12
{
13
    use Queueable;
14
15
    protected $announcement;
16
17
    /**
18
     * Create a new notification instance.
19
     *
20
     * @return void
21
     */
22
    public function __construct(Announcement $announcement)
23
    {
24
        $this->announcement = $announcement;
25
    }
26
27
    /**
28
     * Get the notification's delivery channels.
29
     *
30
     * @param  mixed  $notifiable
31
     * @return array
32
     */
33
    public function via($notifiable)
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

33
    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...
34
    {
35
        return ['slack'];
36
    }
37
38
    /**
39
     * Get the Slack representation of the notification.
40
     *
41
     * @param mixed $notifiable
42
     * @return \Illuminate\Notifications\Messages\SlackMessage
43
     */
44
    public function toSlack($notifiable)
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

44
    public function toSlack(/** @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...
45
    {
46
        return (new SlackMessage)
47
            ->from(setting('title', config('adminetic.title', 'Adminetic')) . ' - ' . $this->announcement->user->name ?? 'N/A')
0 ignored issues
show
Bug introduced by
The function setting was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

47
            ->from(/** @scrutinizer ignore-call */ setting('title', config('adminetic.title', 'Adminetic')) . ' - ' . $this->announcement->user->name ?? 'N/A')
Loading history...
48
            ->image(getLogo())
0 ignored issues
show
Bug introduced by
The function getLogo was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

48
            ->image(/** @scrutinizer ignore-call */ getLogo())
Loading history...
49
            ->content((new HtmlConverter())->convert($this->announcement->body));
50
    }
51
}
52