Authenticatable   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A authenticate() 0 10 4
1
<?php
2
3
namespace Picqer\Financials\Exact\Webhook;
4
5
trait Authenticatable
6
{
7
    public function authenticate($requestContent, $webhookSecret)
8
    {
9
        $matches = [];
10
        $matched = preg_match('/^{"Content":(.*),"HashCode":"(.*)"}$/', $requestContent, $matches);
11
12
        if ($matched === 1 && isset($matches[1]) && isset($matches[2])) {
13
            return $matches[2] === strtoupper(hash_hmac('sha256', $matches[1], $webhookSecret));
14
        }
15
16
        return false;
17
    }
18
}
19