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

Shopify::headers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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