Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3.1406 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | 14 | public function send($notifiable, Notification $notification) |
|
31 | { |
||
32 | 14 | if (! $routing_key = $notifiable->routeNotificationFor('PagerDuty')) { |
|
33 | 2 | return; |
|
34 | } |
||
35 | |||
36 | /** @var PagerDutyMessage $data */ |
||
37 | 12 | $data = $notification->toPagerDuty($notifiable); |
|
38 | 12 | $data->routingKey($routing_key); |
|
39 | |||
40 | try { |
||
41 | 12 | $response = $this->client->post('https://events.pagerduty.com/v2/enqueue', [ |
|
42 | 12 | 'body' => json_encode($data->toArray()), |
|
43 | 12 | ]); |
|
44 | 12 | } catch (\Exception $e) { |
|
45 | 2 | throw CouldNotSendNotification::create($e); |
|
46 | } |
||
47 | |||
48 | 10 | $this->handleResponse($response); |
|
49 | 2 | } |
|
50 | |||
71 |