Completed
Push — master ( 381557...d947b3 )
by Ashley
01:11
created

GitHub   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

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