CallbackRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A validate() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nxmad\Larapay\Requests;
6
7
use Nxmad\Larapay\Abstracts\Gateway;
8
use Nxmad\Larapay\Abstracts\Request;
9
use Nxmad\Larapay\Exceptions\SignatureValidateException;
10
11
class CallbackRequest extends Request
12
{
13
    /**
14
     * CallbackRequest constructor.
15
     *
16
     * @param Gateway $gateway
17
     * @param array $data
18
     *
19
     * @throws SignatureValidateException
20
     */
21
    public function __construct(Gateway $gateway, $data = [])
22
    {
23
        parent::__construct($gateway, $data);
24
25
        if (! $this->validate()) {
26
            throw new SignatureValidateException;
27
        }
28
    }
29
30
    /**
31
     * @return bool
32
     */
33
    protected function validate(): bool
34
    {
35
        return $this->get(self::SIGNATURE) === $this->sign();
36
    }
37
}
38