Total Complexity | 40 |
Total Lines | 401 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 0 | Features | 0 |
Complex classes like InitializeRequest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use InitializeRequest, and based on these observations, apply Extract Interface, too.
1 | <?php declare(strict_types=1); |
||
23 | final class InitializeRequest extends Request |
||
24 | { |
||
25 | const API_PATH = '/Payment/v1/PaymentPage/Initialize'; |
||
26 | const RESPONSE_CLASS = InitializeResponse::class; |
||
27 | |||
28 | const PAYMENT_METHOD_ALIPAY = "ALIPAY"; |
||
29 | const PAYMENT_METHOD_AMEX = "AMEX"; |
||
30 | const PAYMENT_METHOD_BANCONTACT = "BANCONTACT"; |
||
31 | const PAYMENT_METHOD_BONUS = "BONUS"; |
||
32 | const PAYMENT_METHOD_DINERS = "DINERS"; |
||
33 | const PAYMENT_METHOD_DIRECTDEBIT = "DIRECTDEBIT"; |
||
34 | const PAYMENT_METHOD_EPRZELEWY = "EPRZELEWY"; |
||
35 | const PAYMENT_METHOD_EPS = "EPS"; |
||
36 | const PAYMENT_METHOD_GIROPAY = "GIROPAY"; |
||
37 | const PAYMENT_METHOD_IDEAL = "IDEAL"; |
||
38 | const PAYMENT_METHOD_INVOICE = "INVOICE"; |
||
39 | const PAYMENT_METHOD_JCB = "JCB"; |
||
40 | const PAYMENT_METHOD_MAESTRO = "MAESTRO"; |
||
41 | const PAYMENT_METHOD_MASTERCARD = "MASTERCARD"; |
||
42 | const PAYMENT_METHOD_MYONE = "MYONE"; |
||
43 | const PAYMENT_METHOD_PAYPAL = "PAYPAL"; |
||
44 | const PAYMENT_METHOD_PAYDIREKT = "PAYDIREKT"; |
||
45 | const PAYMENT_METHOD_POSTCARD = "POSTCARD"; |
||
46 | const PAYMENT_METHOD_POSTFINANCE = "POSTFINANCE"; |
||
47 | const PAYMENT_METHOD_SAFERPAYTEST = "SAFERPAYTEST"; |
||
48 | const PAYMENT_METHOD_SOFORT = "SOFORT"; |
||
49 | const PAYMENT_METHOD_TWINT = "TWINT"; |
||
50 | const PAYMENT_METHOD_UNIONPAY = "UNIONPAY"; |
||
51 | const PAYMENT_METHOD_VISA = "VISA"; |
||
52 | const PAYMENT_METHOD_VPAY = "VPAY"; |
||
53 | |||
54 | const WALLET_MASTERPASS = "MASTERPASS"; |
||
55 | const WALLET_APPLEPAY = "APPLEPAY"; |
||
56 | |||
57 | const CONDITION_WITH_LIABILITY_SHIFT = 'WITH_LIABILITY_SHIFT'; |
||
58 | const CONDITION_IF_ALLOWED_BY_SCHEME = 'IF_ALLOWED_BY_SCHEME'; |
||
59 | |||
60 | use RequestCommonsTrait; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | * @SerializedName("TerminalId") |
||
65 | */ |
||
66 | private $terminalId; |
||
67 | |||
68 | /** |
||
69 | * @var Payment |
||
70 | * @SerializedName("Payment") |
||
71 | */ |
||
72 | private $payment; |
||
73 | |||
74 | /** |
||
75 | * @var ReturnUrls |
||
76 | * @SerializedName("ReturnUrls") |
||
77 | */ |
||
78 | private $returnUrls; |
||
79 | |||
80 | /** |
||
81 | * @var string|null |
||
82 | * @SerializedName("ConfigSet") |
||
83 | */ |
||
84 | private $configSet; |
||
85 | |||
86 | /** |
||
87 | * @var array<string>|null |
||
88 | * @SerializedName("PaymentMethods") |
||
89 | */ |
||
90 | private $paymentMethods; |
||
91 | |||
92 | /** |
||
93 | * @var PaymentMethodsOptions|null |
||
94 | * @SerializedName("PaymentMethodsOptions") |
||
95 | */ |
||
96 | private $paymentMethodsOptions; |
||
97 | |||
98 | /** |
||
99 | * @var Authentication|null |
||
100 | * @SerializedName("Authentication") |
||
101 | */ |
||
102 | private $authentication; |
||
103 | |||
104 | /** |
||
105 | * @var array<string>|null |
||
106 | * @SerializedName("Wallets") |
||
107 | */ |
||
108 | private $wallets; |
||
109 | |||
110 | /** |
||
111 | * @var Payer|null |
||
112 | * @SerializedName("Payer") |
||
113 | */ |
||
114 | private $payer; |
||
115 | |||
116 | /** |
||
117 | * @var RegisterAlias|null |
||
118 | * @SerializedName("RegisterAlias") |
||
119 | */ |
||
120 | private $registerAlias; |
||
121 | |||
122 | /** |
||
123 | * @var Notification|null |
||
124 | * @SerializedName("Notification") |
||
125 | */ |
||
126 | private $notification; |
||
127 | |||
128 | /** |
||
129 | * @var Styling|null |
||
130 | * @SerializedName("Styling") |
||
131 | */ |
||
132 | private $styling; |
||
133 | |||
134 | /** |
||
135 | * @var AddressForm|null |
||
136 | * @SerializedName("BillingAddressForm") |
||
137 | */ |
||
138 | private $billingAddressForm; |
||
139 | |||
140 | /** |
||
141 | * @var AddressForm|null |
||
142 | * @SerializedName("DeliveryAddressForm") |
||
143 | */ |
||
144 | private $deliveryAddressForm; |
||
145 | |||
146 | /** |
||
147 | * @var CardForm|null |
||
148 | * @SerializedName("CardForm") |
||
149 | */ |
||
150 | private $cardForm; |
||
151 | |||
152 | /** |
||
153 | * @var string|null |
||
154 | * @SerializedName("Condition") |
||
155 | */ |
||
156 | private $condition; |
||
157 | |||
158 | /** |
||
159 | * @var Order|null |
||
160 | * @SerializedName("Order") |
||
161 | */ |
||
162 | private $order; |
||
163 | |||
164 | /** |
||
165 | * @var RiskFactors|null |
||
166 | * @SerializedName("RiskFactors") |
||
167 | */ |
||
168 | private $riskFactors; |
||
169 | |||
170 | /** |
||
171 | * @var string|null |
||
172 | * @SerializedName("LanguageCode") |
||
173 | */ |
||
174 | private $languageCode; |
||
175 | |||
176 | public function __construct( |
||
177 | RequestConfig $requestConfig, |
||
178 | string $terminalId, |
||
179 | Payment $payment, |
||
180 | ReturnUrls $returnUrls |
||
181 | ) { |
||
182 | $this->terminalId = $terminalId; |
||
183 | $this->payment = $payment; |
||
184 | $this->returnUrls = $returnUrls; |
||
185 | |||
186 | parent::__construct($requestConfig); |
||
187 | } |
||
188 | |||
189 | public function getTerminalId(): string |
||
190 | { |
||
191 | return $this->terminalId; |
||
192 | } |
||
193 | |||
194 | public function setTerminalId(string $terminalId): self |
||
195 | { |
||
196 | $this->terminalId = $terminalId; |
||
197 | |||
198 | return $this; |
||
199 | } |
||
200 | |||
201 | public function getPayment(): Payment |
||
202 | { |
||
203 | return $this->payment; |
||
204 | } |
||
205 | |||
206 | public function setPayment(Payment $payment): self |
||
207 | { |
||
208 | $this->payment = $payment; |
||
209 | |||
210 | return $this; |
||
211 | } |
||
212 | |||
213 | public function getReturnUrls(): ReturnUrls |
||
214 | { |
||
215 | return $this->returnUrls; |
||
216 | } |
||
217 | |||
218 | public function setReturnUrls(ReturnUrls $returnUrls): self |
||
219 | { |
||
220 | $this->returnUrls = $returnUrls; |
||
221 | |||
222 | return $this; |
||
223 | } |
||
224 | |||
225 | public function getConfigSet(): ?string |
||
226 | { |
||
227 | return $this->configSet; |
||
228 | } |
||
229 | |||
230 | public function setConfigSet(?string $configSet): self |
||
231 | { |
||
232 | $this->configSet = $configSet; |
||
233 | |||
234 | return $this; |
||
235 | } |
||
236 | |||
237 | public function getPaymentMethods(): ?array |
||
238 | { |
||
239 | return $this->paymentMethods; |
||
240 | } |
||
241 | |||
242 | public function setPaymentMethods(?array $paymentMethods): self |
||
243 | { |
||
244 | $this->paymentMethods = $paymentMethods; |
||
245 | |||
246 | return $this; |
||
247 | } |
||
248 | |||
249 | public function getPaymentMethodsOptions(): ?PaymentMethodsOptions |
||
250 | { |
||
251 | return $this->paymentMethodsOptions; |
||
252 | } |
||
253 | |||
254 | public function setPaymentMethodsOptions(?PaymentMethodsOptions $paymentMethodsOptions): self |
||
255 | { |
||
256 | $this->paymentMethodsOptions = $paymentMethodsOptions; |
||
257 | |||
258 | return $this; |
||
259 | } |
||
260 | |||
261 | public function getAuthentication(): ?Authentication |
||
262 | { |
||
263 | return $this->authentication; |
||
264 | } |
||
265 | |||
266 | public function setAuthentication(?Authentication $authentication): self |
||
267 | { |
||
268 | $this->authentication = $authentication; |
||
269 | |||
270 | return $this; |
||
271 | } |
||
272 | |||
273 | public function getWallets(): ?array |
||
274 | { |
||
275 | return $this->wallets; |
||
276 | } |
||
277 | |||
278 | public function setWallets(?array $wallets): self |
||
279 | { |
||
280 | $this->wallets = $wallets; |
||
281 | |||
282 | return $this; |
||
283 | } |
||
284 | |||
285 | public function getPayer(): ?Payer |
||
286 | { |
||
287 | return $this->payer; |
||
288 | } |
||
289 | |||
290 | public function setPayer(?Payer $payer): self |
||
291 | { |
||
292 | $this->payer = $payer; |
||
293 | |||
294 | return $this; |
||
295 | } |
||
296 | |||
297 | public function getRegisterAlias(): ?RegisterAlias |
||
298 | { |
||
299 | return $this->registerAlias; |
||
300 | } |
||
301 | |||
302 | public function setRegisterAlias(?RegisterAlias $registerAlias): self |
||
303 | { |
||
304 | $this->registerAlias = $registerAlias; |
||
305 | |||
306 | return $this; |
||
307 | } |
||
308 | |||
309 | public function getNotification(): ?Notification |
||
310 | { |
||
311 | return $this->notification; |
||
312 | } |
||
313 | |||
314 | public function setNotification(?Notification $notification): self |
||
315 | { |
||
316 | $this->notification = $notification; |
||
317 | |||
318 | return $this; |
||
319 | } |
||
320 | |||
321 | public function getStyling(): ?Styling |
||
322 | { |
||
323 | return $this->styling; |
||
324 | } |
||
325 | |||
326 | public function setStyling(?Styling $styling): self |
||
327 | { |
||
328 | $this->styling = $styling; |
||
329 | |||
330 | return $this; |
||
331 | } |
||
332 | |||
333 | public function getBillingAddressForm(): ?AddressForm |
||
334 | { |
||
335 | return $this->billingAddressForm; |
||
336 | } |
||
337 | |||
338 | public function setBillingAddressForm(?AddressForm $billingAddressForm): self |
||
339 | { |
||
340 | $this->billingAddressForm = $billingAddressForm; |
||
341 | |||
342 | return $this; |
||
343 | } |
||
344 | |||
345 | public function getDeliveryAddressForm(): ?AddressForm |
||
346 | { |
||
347 | return $this->deliveryAddressForm; |
||
348 | } |
||
349 | |||
350 | public function setDeliveryAddressForm(?AddressForm $deliveryAddressForm): self |
||
351 | { |
||
352 | $this->deliveryAddressForm = $deliveryAddressForm; |
||
353 | |||
354 | return $this; |
||
355 | } |
||
356 | |||
357 | public function getCardForm(): ?CardForm |
||
358 | { |
||
359 | return $this->cardForm; |
||
360 | } |
||
361 | |||
362 | public function setCardForm(?CardForm $cardForm): self |
||
363 | { |
||
364 | $this->cardForm = $cardForm; |
||
365 | |||
366 | return $this; |
||
367 | } |
||
368 | |||
369 | public function getCondition(): ?string |
||
370 | { |
||
371 | return $this->condition; |
||
372 | } |
||
373 | |||
374 | public function setCondition(?string $condition): self |
||
375 | { |
||
376 | $this->condition = $condition; |
||
377 | |||
378 | return $this; |
||
379 | } |
||
380 | |||
381 | public function getOrder(): ?Order |
||
382 | { |
||
383 | return $this->order; |
||
384 | } |
||
385 | |||
386 | public function setOrder(?Order $order): self |
||
387 | { |
||
388 | $this->order = $order; |
||
389 | |||
390 | return $this; |
||
391 | } |
||
392 | |||
393 | public function getRiskFactors(): ?RiskFactors |
||
394 | { |
||
395 | return $this->riskFactors; |
||
396 | } |
||
397 | |||
398 | public function setRiskFactors(?RiskFactors $riskFactors): self |
||
399 | { |
||
400 | $this->riskFactors = $riskFactors; |
||
401 | |||
402 | return $this; |
||
403 | } |
||
404 | |||
405 | public function getLanguageCode(): ?string |
||
408 | } |
||
409 | |||
410 | public function setLanguageCode(?string $languageCode): self |
||
411 | { |
||
412 | $this->languageCode = $languageCode; |
||
413 | |||
414 | return $this; |
||
415 | } |
||
416 | |||
417 | |||
418 | public function execute(): InitializeResponse |
||
419 | { |
||
420 | /** @var InitializeResponse $response */ |
||
421 | $response = $this->doExecute(); |
||
422 | |||
423 | return $response; |
||
424 | } |
||
425 | } |
||
426 |