Conditions | 4 |
Paths | 7 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
23 | 6 | public function handle() |
|
24 | { |
||
25 | try { |
||
26 | 6 | if (! $body = $this->getRawBody()) { |
|
27 | 2 | throw new \Exception('Empty post body!'); |
|
28 | } |
||
29 | |||
30 | 4 | if (! $decoded = json_decode($body)) { |
|
31 | 2 | throw new \Exception('Unable to decode JSON from post body!'); |
|
32 | } |
||
33 | |||
34 | 2 | reset($decoded); |
|
35 | 2 | $event = current($decoded); // get first attribute from array, e.g.: event. |
|
36 | |||
37 | 2 | return $event; |
|
38 | 4 | } catch (\Exception $e) { |
|
39 | 4 | throw new WebhookHandleException($e->getMessage(), $e->getCode(), $e); |
|
40 | } |
||
41 | } |
||
42 | |||
51 |