Conditions | 4 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
14 | public function subscribe(Dispatcher $events) |
||
15 | { |
||
16 | // Listen events and send notification |
||
17 | $events->listen(UnitPayEvent::class, function ($event) { |
||
18 | $event->type = str_replace('unitpay.', '', $event->type); |
||
19 | |||
20 | if (! in_array($event->type, ['info', 'success', 'error'])) { |
||
21 | $event->type = 'error'; |
||
22 | } |
||
23 | |||
24 | $notifiable = app(config('unitpay.notifiable')); |
||
25 | |||
26 | $notification = app(config('unitpay.notification')); |
||
27 | $notification->setEvent($event); |
||
28 | |||
29 | if (! $this->isValidNotificationClass($notification)) { |
||
30 | throw InvalidConfiguration::notificationClassInvalid(get_class($notification)); |
||
31 | } |
||
32 | |||
33 | if ($this->shouldSendNotification($notification)) { |
||
34 | $notifiable->notify($notification); |
||
35 | } |
||
36 | }); |
||
37 | } |
||
38 | |||
63 |