diff --git a/src/App/Webhook/PdkWebhookManager.php b/src/App/Webhook/PdkWebhookManager.php index 503d6f711..aa5fc1977 100644 --- a/src/App/Webhook/PdkWebhookManager.php +++ b/src/App/Webhook/PdkWebhookManager.php @@ -120,14 +120,14 @@ private function getHooks(Request $request): array $headers = $request->headers->all(); $body = json_decode($request->getContent(), true); - if (isset($headers['x-myparcel-hook'])) { - $body['data']['hooks'] = array_map(function ($hook) use ($headers) { - $hook['event'] = $headers['x-myparcel-hook'][0]; - - return $hook; - }, $body['data']['hooks']); + if (! isset($headers['x-myparcel-hook'])) { + return $body['data']['hooks'] ?? []; } - return $body['data']['hooks'] ?? []; + return array_map(static function ($hook) use ($headers) { + $hook['event'] = $headers['x-myparcel-hook'][0]; + + return $hook; + }, $body['data']['hooks']); } }