Completed
Pull Request — master (#32)
by Sullivan
02:43
created

AbstractResponse::getCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Nexy\PayboxDirect\Response;
4
5
/**
6
 * @author Sullivan Senechal <[email protected]>
7
 */
8
abstract class AbstractResponse implements ResponseInterface
9
{
10
    /**
11
     * @var int
12
     */
13
    private $code;
14
15
    /**
16
     * @var string
17
     */
18
    private $comment;
19
20
    /**
21
     * @var string
22
     */
23
    private $site;
24
25
    /**
26
     * @var string
27
     */
28
    private $rank;
29
30
    /**
31
     * @var int
32
     */
33
    private $callNumber;
34
35
    /**
36
     * @var int
37
     */
38
    private $questionNumber;
39
40
    /**
41
     * @var int
42
     */
43
    private $transactionNumber;
44
45
    /**
46
     * @var string|null|false
47
     */
48
    private $authorization = null;
49
50
    /**
51
     * @var string|null|false
52
     */
53
    private $country = null;
54
55
    /**
56
     * @var string|null|false
57
     */
58
    private $sha1 = null;
59
60
    /**
61
     * @var string|null|false
62
     */
63
    private $cardType = null;
64
65
    /**
66
     * @param string[] $data
67
     */
68
    public function __construct(array $data)
69
    {
70
        $this->code = intval($data['CODEREPONSE']);
71
        $this->comment = $data['COMMENTAIRE'];
72
        $this->site = $data['SITE'];
73
        $this->rank = $data['RANG'];
74
        $this->callNumber = intval($data['NUMAPPEL']);
75
        $this->questionNumber = intval($data['NUMQUESTION']);
76
        $this->transactionNumber = intval($data['NUMTRANS']);
77
78
        if (array_key_exists('AUTORISATION', $data)) {
79
            $this->authorization = '' === $data['AUTORISATION'] ? false : $data['AUTORISATION'];
80
        }
81
        if (array_key_exists('PAYS', $data)) {
82
            $this->country = in_array($data['PAYS'], ['', '???'], true) ? false : $data['PAYS'];
83
        }
84
        if (array_key_exists('SHA-1', $data)) {
85
            $this->sha1 = '' === $data['SHA-1'] ? false : $data['SHA-1'];
86
        }
87
        if (array_key_exists('TYPECARTE', $data)) {
88
            $this->cardType = '' === $data['TYPECARTE'] ? false : $data['TYPECARTE'];
89
        }
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    final public function getCode()
96
    {
97
        return $this->code;
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    final public function getComment()
104
    {
105
        return $this->comment;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    final public function getSite()
112
    {
113
        return $this->site;
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    final public function getRank()
120
    {
121
        return $this->rank;
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    final public function getCallNumber()
128
    {
129
        return $this->callNumber;
130
    }
131
132
    /**
133
     * {@inheritdoc}
134
     */
135
    final public function getQuestionNumber()
136
    {
137
        return $this->questionNumber;
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143
    final public function getTransactionNumber()
144
    {
145
        return $this->transactionNumber;
146
    }
147
148
    /**
149
     * {@inheritdoc}
150
     */
151
    public function getAuthorization()
152
    {
153
        return $this->authorization;
154
    }
155
156
    /**
157
     * {@inheritdoc}
158
     */
159
    public function getCountry()
160
    {
161
        return $this->country;
162
    }
163
164
    /**
165
     * {@inheritdoc}
166
     */
167
    final public function getSha1()
168
    {
169
        return $this->sha1;
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175
    public function getCardType()
176
    {
177
        return $this->cardType;
178
    }
179
}
180