WebMoneyMerchantNotification::getEvent()   A
last analyzed

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