| Total Complexity | 7 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 6 | ||
| Bugs | 4 | Features | 2 |
| 1 | <?php |
||
| 11 | class WebhookController extends Controller |
||
| 12 | { |
||
| 13 | public function __construct() |
||
| 16 | } |
||
| 17 | |||
| 18 | public function __invoke(Request $request) |
||
| 19 | { |
||
| 20 | $eventPayload = $this->getJsonPayloadFromRequest($request); |
||
| 21 | if (! isset($eventPayload['type'])) { |
||
| 22 | throw WebhookFailed::missingType($request); |
||
| 23 | } |
||
| 24 | $type = $eventPayload['type']; |
||
| 25 | $WebhookCall = new WebhookCall($eventPayload); |
||
|
|
|||
| 26 | event("multicoin-webhooks::{$type}", $WebhookCall); |
||
| 27 | $jobClass = $this->determineJobClass($type); |
||
| 28 | if ('' === $jobClass) { |
||
| 29 | return; |
||
| 30 | } |
||
| 31 | if (! class_exists($jobClass)) { |
||
| 32 | throw WebhookFailed::jobClassDoesNotExist($jobClass, $WebhookCall); |
||
| 33 | } |
||
| 34 | dispatch(new $jobClass($WebhookCall)); |
||
| 35 | } |
||
| 36 | |||
| 37 | protected function determineJobClass(string $type) |
||
| 40 | } |
||
| 41 | |||
| 42 | private function getJsonPayloadFromRequest($request) |
||
| 47 |