Passed
Push — master ( 40cb89...896f76 )
by Action
02:45
created

UnitPayNotification::getEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace ActionM\UnitPay;
4
5
use ActionM\UnitPay\Events\UnitPayEvent;
6
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Contracts\Queue\ShouldQueue;
9
10
use Illuminate\Notifications\Messages\MailMessage;
11
use Illuminate\Notifications\Messages\SlackMessage;
12
use Illuminate\Notifications\Messages\SlackAttachment;
13
use Illuminate\Notifications\Notification;
14
15
class UnitPayNotification extends Notification implements ShouldQueue
16
{
17
    use Queueable;
18
19
    /** @var \ActionM\UnitPay\Events\UnitPayEvent * */
20
    protected $event;
21
22
    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...
23
    {
24
        return config('unitpay.channels');
25
    }
26
27
    public function setEvent(UnitPayEvent $event)
28
    {
29
        $this->event = $event;
30
31
        return $this;
32
    }
33
34
    public function getEvent()
35
    {
36
        return $this->event;
37
    }
38
39
    public function toMail($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...
40
    {
41
        return (new MailMessage)
42
            ->error()
43
            ->subject('UnitPay payment message from '.config('app.url'))
44
            ->line($this->event->title)
45
            ->line('IP: '.$this->event->ip)
46
            ->line("Request details: {$this->event->details}");
47
    }
48
49
    public function toSlack()
50
    {
51
        $slack_message = new SlackMessage();
52
        $slack_message->level = $this->event->type;
53
54
        return $slack_message
55
            ->content('UnitPay payment message from '.config('app.url'))
56
            ->attachment(function (SlackAttachment $attachment) {
57
                $attachment->fields([
58
                    'Title' => $this->event->title,
59
                    'IP' => $this->event->ip,
60
                    'Request details' => $this->event->details,
61
                ]);
62
            });
63
    }
64
}
65