BitBucketServer::verify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
namespace Shield\BitBucketServer;
3
use Illuminate\Http\Request;
4
use Illuminate\Support\Collection;
5
use Shield\Shield\Contracts\Service;
6
/**
7
 * Class BitBucketServer
8
 *
9
 * @package \Shield\BitBucketServer
10
 */
11
class BitBucketServer implements Service
12
{
13 2
    public function verify(Request $request, Collection $config): bool
14
    {
15 2
        $generatedHash = hash_hmac('sha256', $request->getContent(), $config->get('token'));
16 2
        return hash_equals($generatedHash, $request->header('X-Hub-Signature'));
17
    }
18 1
    public function headers(): array
19
    {
20 1
        return ['X-Hub-Signature'];
21
    }
22
}