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
|
|
|
// Cleanup array to set false for empty/invalid values. |
71
|
|
|
array_walk($data, function (&$value) { |
72
|
|
|
if (in_array($value, ['', '???'], true)) { |
73
|
|
|
$value = false; |
74
|
|
|
} |
75
|
|
|
}); |
76
|
|
|
|
77
|
|
|
$this->code = intval($data['CODEREPONSE']); |
78
|
|
|
$this->comment = $data['COMMENTAIRE']; |
79
|
|
|
$this->site = $data['SITE']; |
80
|
|
|
$this->rank = $data['RANG']; |
81
|
|
|
$this->callNumber = intval($data['NUMAPPEL']); |
82
|
|
|
$this->questionNumber = intval($data['NUMQUESTION']); |
83
|
|
|
$this->transactionNumber = intval($data['NUMTRANS']); |
84
|
|
|
|
85
|
|
|
if (array_key_exists('AUTORISATION', $data)) { |
86
|
|
|
$this->authorization = $data['AUTORISATION']; |
87
|
|
|
} |
88
|
|
|
if (array_key_exists('PAYS', $data)) { |
89
|
|
|
$this->country = $data['PAYS']; |
90
|
|
|
} |
91
|
|
|
if (array_key_exists('SHA-1', $data)) { |
92
|
|
|
$this->sha1 = $data['SHA-1']; |
93
|
|
|
} |
94
|
|
|
if (array_key_exists('TYPECARTE', $data)) { |
95
|
|
|
$this->cardType = $data['TYPECARTE']; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
final public function getCode() |
103
|
|
|
{ |
104
|
|
|
return $this->code; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* {@inheritdoc} |
109
|
|
|
*/ |
110
|
|
|
final public function getComment() |
111
|
|
|
{ |
112
|
|
|
return $this->comment; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* {@inheritdoc} |
117
|
|
|
*/ |
118
|
|
|
final public function getSite() |
119
|
|
|
{ |
120
|
|
|
return $this->site; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* {@inheritdoc} |
125
|
|
|
*/ |
126
|
|
|
final public function getRank() |
127
|
|
|
{ |
128
|
|
|
return $this->rank; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* {@inheritdoc} |
133
|
|
|
*/ |
134
|
|
|
final public function getCallNumber() |
135
|
|
|
{ |
136
|
|
|
return $this->callNumber; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* {@inheritdoc} |
141
|
|
|
*/ |
142
|
|
|
final public function getQuestionNumber() |
143
|
|
|
{ |
144
|
|
|
return $this->questionNumber; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* {@inheritdoc} |
149
|
|
|
*/ |
150
|
|
|
final public function getTransactionNumber() |
151
|
|
|
{ |
152
|
|
|
return $this->transactionNumber; |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* {@inheritdoc} |
157
|
|
|
*/ |
158
|
|
|
public function getAuthorization() |
159
|
|
|
{ |
160
|
|
|
return $this->authorization; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* {@inheritdoc} |
165
|
|
|
*/ |
166
|
|
|
public function getCountry() |
167
|
|
|
{ |
168
|
|
|
return $this->country; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* {@inheritdoc} |
173
|
|
|
*/ |
174
|
|
|
final public function getSha1() |
175
|
|
|
{ |
176
|
|
|
return $this->sha1; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* {@inheritdoc} |
181
|
|
|
*/ |
182
|
|
|
public function getCardType() |
183
|
|
|
{ |
184
|
|
|
return $this->cardType; |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|