WebhookValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 3
c 2
b 0
f 0
dl 0
loc 11
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A isValid() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Esa;
6
7
class WebhookValidator
8
{
9 5
    public function __construct(private string $secret)
10
    {
11
    }
12
13 5
    public function isValid(string $payload, string $signature): bool
14
    {
15 5
        $hash = hash_hmac('sha256', $payload, $this->secret);
16
17 5
        return sprintf('sha256=%s', $hash) === $signature;
18
    }
19
}
20