Passed
Pull Request — master (#6)
by Mattia
32:50 queued 25:28
created

IgfsCgTokenizerDelete   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 70.83%

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 59
ccs 17
cts 24
cp 0.7083
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A checkFields() 0 5 2
A resetFields() 0 5 1
A buildRequest() 0 7 1
A getResponseSignature() 0 9 1
A getAdditionalRequestSignatureFields() 0 4 1
1
<?php
2
3
namespace PagOnline\Tokenizer;
4
5
use PagOnline\Exceptions\IgfsMissingParException;
6
use PagOnline\IgfsUtils;
7
8
class IgfsCgTokenizerDelete extends BaseIgfsCgTokenizer
9
{
10
    public $payInstrToken;
11
    public $billingID;
12
    /**
13
     * @var string
14
     */
15
    protected $requestNamespace = Requests\IgfsCgTokenizerDeleteRequest::class;
16
17 1
    public function resetFields()
18
    {
19 1
        parent::resetFields();
20 1
        $this->payInstrToken = null;
21 1
        $this->billingID = null;
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    protected function getAdditionalRequestSignatureFields(): array
28
    {
29 1
        return [
30 1
            $this->payInstrToken,
31 1
        ];
32
    }
33
34 6
    protected function checkFields()
35
    {
36 6
        parent::checkFields();
37 2
        if ($this->payInstrToken == null) {
38 1
            throw new IgfsMissingParException('Missing payInstrToken');
39
        }
40
    }
41
42 1
    protected function buildRequest()
43
    {
44 1
        $request = parent::buildRequest();
45 1
        $this->replaceRequestParameter($request, 'payInstrToken', $this->payInstrToken);
46 1
        $this->replaceRequestParameter($request, 'billingID', $this->billingID);
47
48 1
        return $request;
49
    }
50
51
    /**
52
     * @param array $response
53
     *
54
     * @throws \PagOnline\Exceptions\IgfsException
55
     *
56
     * @return string
57
     */
58
    protected function getResponseSignature($response)
59
    {
60
        $fields = [
61
            IgfsUtils::getValue($response, 'tid'), // TID
62
            IgfsUtils::getValue($response, 'shopID'), // SHOPID
63
            IgfsUtils::getValue($response, 'rc'), // RC
64
            IgfsUtils::getValue($response, 'errorDesc'), ]; // ERRORDESC
65
        // signature dove il buffer e' cosi composto TID|SHOPID|RC|ERRORDESC
66
        return $this->getSignature($fields);
67
    }
68
}
69