GitHub   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A verify() 0 6 1
A headers() 0 4 1
1
<?php
2
3
namespace Shield\GitHub;
4
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Collection;
7
use Shield\Shield\Contracts\Service;
8
9
/**
10
 * Class GitHub
11
 *
12
 * @package \Shield\GitHub
13
 */
14
class GitHub implements Service
15
{
16 2
    public function verify(Request $request, Collection $config): bool
17
    {
18 2
        $generated = 'sha1=' . hash_hmac('sha1', $request->getContent(), $config->get('token'));
19
20 2
        return hash_equals($generated, $request->header('X-Hub-Signature'));
21
    }
22
23 1
    public function headers(): array
24
    {
25 1
        return ['X-Hub-Signature'];
26
    }
27
}
28