Completed
Pull Request — master (#9)
by Alexander
01:07
created

Shopify   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A verify() 0 17 1
A headers() 0 4 1
1
<?php
2
3
namespace Clarkeash\Shield\Services;
4
5
use Illuminate\Http\Request;
6
7
class Shopify extends BaseService
8
{
9
    public function verify(Request $request): bool
10
    {
11
12
        $generated = base64_encode(
13
            hash_hmac(
14
                'sha256',
15
                $request->getContent(),
16
                config("shield.services.shopify.token"),
17
                true
18
            )
19
        );
20
21
        return hash_equals(
22
            $generated,
23
            $this->header($request, 'X-Shopify-Hmac-SHA256')
24
        );
25
    }
26
27
    public function headers(): array
28
    {
29
        return ['X-Shopify-Hmac-SHA256'];
30
    }
31
}
32