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