| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public function isValid(Request $request, WebhookConfig $config): bool |
||
| 12 | { |
||
| 13 | $signature = $request->header($config->signatureHeaderName); |
||
| 14 | |||
| 15 | if (! $signature) { |
||
| 16 | return false; |
||
| 17 | } |
||
| 18 | |||
| 19 | $signingSecret = $config->signingSecret; |
||
| 20 | |||
| 21 | if (empty($signingSecret)) { |
||
| 22 | throw WebhookFailed::signingSecretNotSet(); |
||
| 23 | } |
||
| 24 | |||
| 25 | $computedSignature = hash_hmac('sha256', $request->getContent(), $signingSecret); |
||
| 26 | |||
| 27 | return hash_equals($signature, $computedSignature); |
||
| 28 | } |
||
| 29 | } |
||
| 30 |