BaseIgfsCgTran   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 73.32%

Importance

Changes 0
Metric Value
eloc 32
c 0
b 0
f 0
dl 0
loc 64
ccs 22
cts 30
cp 0.7332
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A buildRequest() 0 10 1
A resetFields() 0 9 1
A parseResponseMap() 0 15 1
A getServicePort() 0 3 1
A checkFields() 0 5 2
1
<?php
2
3
namespace PagOnline\Tran;
4
5
use PagOnline\BaseIgfsCg;
6
use PagOnline\Exceptions\IgfsMissingParException;
7
use PagOnline\IgfsUtils;
8
9
/**
10
 * Class BaseIgfsCgTran.
11
 */
12
abstract class BaseIgfsCgTran extends BaseIgfsCg
13
{
14
    public $addInfo1;
15
    public $addInfo2;
16
    public $addInfo3;
17
    public $addInfo4;
18
    public $addInfo5;
19
20
    public $tranID;
21
22 4
    public function resetFields(): void
23
    {
24 4
        parent::resetFields();
25 4
        $this->addInfo1 = null;
26 4
        $this->addInfo2 = null;
27 4
        $this->addInfo3 = null;
28 4
        $this->addInfo4 = null;
29 4
        $this->addInfo5 = null;
30 4
        $this->tranID = null;
31
    }
32
33 24
    protected function checkFields(): void
34
    {
35 24
        parent::checkFields();
36 9
        if (empty($this->shopID)) {
37 4
            throw new IgfsMissingParException('Missing shopID');
38
        }
39
    }
40
41 4
    protected function buildRequest()
42
    {
43 4
        $request = parent::buildRequest();
44 4
        $this->replaceRequestParameter($request, 'addInfo1', $this->addInfo1);
45 4
        $this->replaceRequestParameter($request, 'addInfo2', $this->addInfo2);
46 4
        $this->replaceRequestParameter($request, 'addInfo3', $this->addInfo3);
47 4
        $this->replaceRequestParameter($request, 'addInfo4', $this->addInfo4);
48 4
        $this->replaceRequestParameter($request, 'addInfo5', $this->addInfo5);
49
50 4
        return $request;
51
    }
52
53 8
    protected function getServicePort(): string
54
    {
55 8
        return 'PaymentTranGatewayPort';
56
    }
57
58
    /**
59
     * @param array $response
60
     */
61
    protected function parseResponseMap($response): void
62
    {
63
        parent::parseResponseMap($response);
64
        // Opzionale
65
        $this->tranID = IgfsUtils::getValue($response, 'tranID');
66
        // Opzionale
67
        $this->addInfo1 = IgfsUtils::getValue($response, 'addInfo1');
68
        // Opzionale
69
        $this->addInfo2 = IgfsUtils::getValue($response, 'addInfo2');
70
        // Opzionale
71
        $this->addInfo3 = IgfsUtils::getValue($response, 'addInfo3');
72
        // Opzionale
73
        $this->addInfo4 = IgfsUtils::getValue($response, 'addInfo4');
74
        // Opzionale
75
        $this->addInfo5 = IgfsUtils::getValue($response, 'addInfo5');
76
    }
77
}
78