Total Complexity | 40 |
Total Lines | 504 |
Duplicated Lines | 0 % |
Changes | 15 | ||
Bugs | 0 | Features | 3 |
Complex classes like ComputopConfig 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 ComputopConfig, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
15 | class ComputopConfig extends AbstractBundleConfig |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | public const OMS_STATUS_NEW = 'new'; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | public const OMS_STATUS_INITIALIZED = 'init'; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | public const OMS_STATUS_AUTHORIZED = 'authorized'; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | public const OMS_STATUS_AUTHORIZATION_FAILED = 'authorization failed'; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | public const OMS_STATUS_CAPTURED = 'captured'; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | public const OMS_STATUS_CAPTURING_FAILED = 'capture failed'; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | public const OMS_STATUS_CANCELLED = 'cancelled'; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | */ |
||
55 | public const OMS_STATUS_REFUNDED = 'refunded'; |
||
56 | |||
57 | /** |
||
58 | * @var string |
||
59 | */ |
||
60 | public const AUTHORIZE_METHOD = 'AUTHORIZE'; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | public const CAPTURE_METHOD = 'CAPTURE'; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | */ |
||
70 | public const REVERSE_METHOD = 'REVERSE'; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | */ |
||
75 | public const INQUIRE_METHOD = 'INQUIRE'; |
||
76 | |||
77 | /** |
||
78 | * @var string |
||
79 | */ |
||
80 | public const REFUND_METHOD = 'REFUND'; |
||
81 | |||
82 | //Events |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | */ |
||
87 | public const COMPUTOP_OMS_EVENT_CAPTURE = 'capture'; |
||
88 | |||
89 | /** |
||
90 | * @var string |
||
91 | */ |
||
92 | public const COMPUTOP_OMS_EVENT_AUTHORIZE = 'authorize'; |
||
93 | |||
94 | /** |
||
95 | * Refund with shipment price |
||
96 | * |
||
97 | * @var bool |
||
98 | */ |
||
99 | public const COMPUTOP_REFUND_SHIPMENT_PRICE_ENABLED = true; |
||
100 | |||
101 | /** |
||
102 | * @var string |
||
103 | */ |
||
104 | protected const OMS_STATUS_AUTHORIZE_REQUEST = 'authorize request'; |
||
105 | |||
106 | /** |
||
107 | * @api |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getMerchantId() |
||
112 | { |
||
113 | return $this->get(ComputopApiConstants::MERCHANT_ID); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @api |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | public function getBlowfishPass() |
||
122 | { |
||
123 | return $this->get(ComputopApiConstants::BLOWFISH_PASSWORD); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @api |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function getAuthorizeAction() |
||
132 | { |
||
133 | return $this->get(ComputopConstants::AUTHORIZE_ACTION); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * @api |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | public function getCaptureAction() |
||
142 | { |
||
143 | return $this->get(ComputopConstants::CAPTURE_ACTION); |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @api |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | public function getRefundAction() |
||
152 | { |
||
153 | return $this->get(ComputopConstants::REFUND_ACTION); |
||
154 | } |
||
155 | |||
156 | /** |
||
157 | * @api |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | public function getInquireAction() |
||
162 | { |
||
163 | return $this->get(ComputopConstants::INQUIRE_ACTION); |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * @api |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getReverseAction() |
||
172 | { |
||
173 | return $this->get(ComputopConstants::REVERSE_ACTION); |
||
174 | } |
||
175 | |||
176 | /** |
||
177 | * @api |
||
178 | * |
||
179 | * @return string |
||
180 | */ |
||
181 | public function getIdealInitAction() |
||
182 | { |
||
183 | return $this->get(ComputopConstants::IDEAL_INIT_ACTION); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @api |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | public function getPaydirektInitAction() |
||
192 | { |
||
193 | return $this->get(ComputopConstants::PAYDIREKT_INIT_ACTION); |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * @api |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | public function getPayuCeeSingleInitAction(): string |
||
202 | { |
||
203 | return $this->get(ComputopConstants::PAYU_CEE_SINGLE_INIT_ACTION); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * @api |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | public function getSofortInitAction() |
||
212 | { |
||
213 | return $this->get(ComputopConstants::SOFORT_INIT_ACTION); |
||
214 | } |
||
215 | |||
216 | /** |
||
217 | * @api |
||
218 | * |
||
219 | * @return string |
||
220 | */ |
||
221 | public function getEasyCreditStatusUrl() |
||
222 | { |
||
223 | return $this->get(ComputopConstants::EASY_CREDIT_STATUS_ACTION); |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * @api |
||
228 | * |
||
229 | * @return string |
||
230 | */ |
||
231 | public function getEasyCreditAuthorizeUrl() |
||
232 | { |
||
233 | return $this->get(ComputopConstants::EASY_CREDIT_AUTHORIZE_ACTION); |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * @api |
||
238 | * |
||
239 | * @return string |
||
240 | */ |
||
241 | public function getPayNowInitActionUrl() |
||
242 | { |
||
243 | return $this->get(ComputopConstants::PAY_NOW_INIT_ACTION); |
||
244 | } |
||
245 | |||
246 | /** |
||
247 | * @api |
||
248 | * |
||
249 | * @return bool |
||
250 | */ |
||
251 | public function isRefundShipmentPriceEnabled() |
||
252 | { |
||
253 | return static::COMPUTOP_REFUND_SHIPMENT_PRICE_ENABLED; |
||
254 | } |
||
255 | |||
256 | /** |
||
257 | * @api |
||
258 | * |
||
259 | * @return array |
||
260 | */ |
||
261 | public function getBeforeCaptureStatuses() |
||
262 | { |
||
263 | return [ |
||
264 | $this->getOmsStatusNew(), |
||
265 | $this->getOmsStatusAuthorized(), |
||
266 | $this->getOmsStatusAuthorizationFailed(), |
||
267 | $this->getOmsStatusCancelled(), |
||
268 | ]; |
||
269 | } |
||
270 | |||
271 | /** |
||
272 | * @api |
||
273 | * |
||
274 | * @return array |
||
275 | */ |
||
276 | public function getBeforeRefundStatuses() |
||
277 | { |
||
278 | return [ |
||
279 | $this->getOmsStatusNew(), |
||
280 | $this->getOmsStatusAuthorized(), |
||
281 | $this->getOmsStatusCaptured(), |
||
282 | ]; |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * @api |
||
287 | * |
||
288 | * @return string |
||
289 | */ |
||
290 | public function getOmsStatusNew() |
||
291 | { |
||
292 | return static::OMS_STATUS_NEW; |
||
293 | } |
||
294 | |||
295 | /** |
||
296 | * @api |
||
297 | * |
||
298 | * @return string |
||
299 | */ |
||
300 | public function getOmsStatusInitialized() |
||
301 | { |
||
302 | return static::OMS_STATUS_INITIALIZED; |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @api |
||
307 | * |
||
308 | * @return string |
||
309 | */ |
||
310 | public function getOmsStatusAuthorized() |
||
311 | { |
||
312 | return static::OMS_STATUS_AUTHORIZED; |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @api |
||
317 | * |
||
318 | * @return string |
||
319 | */ |
||
320 | public function getAuthorizeRequestOmsStatus(): string |
||
321 | { |
||
322 | return static::OMS_STATUS_AUTHORIZE_REQUEST; |
||
323 | } |
||
324 | |||
325 | /** |
||
326 | * @api |
||
327 | * |
||
328 | * @return string |
||
329 | */ |
||
330 | public function getOmsStatusAuthorizationFailed() |
||
331 | { |
||
332 | return static::OMS_STATUS_AUTHORIZATION_FAILED; |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * @api |
||
337 | * |
||
338 | * @return string |
||
339 | */ |
||
340 | public function getOmsStatusCaptured() |
||
341 | { |
||
342 | return static::OMS_STATUS_CAPTURED; |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * @api |
||
347 | * |
||
348 | * @return string |
||
349 | */ |
||
350 | public function getOmsStatusCapturingFailed() |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @api |
||
357 | * |
||
358 | * @return string |
||
359 | */ |
||
360 | public function getOmsStatusCancelled() |
||
361 | { |
||
362 | return static::OMS_STATUS_CANCELLED; |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * @api |
||
367 | * |
||
368 | * @return string |
||
369 | */ |
||
370 | public function getOmsStatusRefunded() |
||
371 | { |
||
372 | return static::OMS_STATUS_REFUNDED; |
||
373 | } |
||
374 | |||
375 | /** |
||
376 | * @api |
||
377 | * |
||
378 | * @return string |
||
379 | */ |
||
380 | public function getAuthorizeMethodName() |
||
381 | { |
||
382 | return static::AUTHORIZE_METHOD; |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * @api |
||
387 | * |
||
388 | * @return string |
||
389 | */ |
||
390 | public function getCaptureMethodName() |
||
391 | { |
||
392 | return static::CAPTURE_METHOD; |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * @api |
||
397 | * |
||
398 | * @return string |
||
399 | */ |
||
400 | public function getRefundMethodName() |
||
401 | { |
||
402 | return static::REFUND_METHOD; |
||
403 | } |
||
404 | |||
405 | /** |
||
406 | * @api |
||
407 | * |
||
408 | * @return string |
||
409 | */ |
||
410 | public function getReverseMethodName() |
||
411 | { |
||
412 | return static::REVERSE_METHOD; |
||
413 | } |
||
414 | |||
415 | /** |
||
416 | * @api |
||
417 | * |
||
418 | * @return string |
||
419 | */ |
||
420 | public function getInquireMethodName() |
||
421 | { |
||
422 | return static::INQUIRE_METHOD; |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * @api |
||
427 | * |
||
428 | * @return string |
||
429 | */ |
||
430 | public function getOmsAuthorizeEventName() |
||
431 | { |
||
432 | return static::COMPUTOP_OMS_EVENT_AUTHORIZE; |
||
433 | } |
||
434 | |||
435 | /** |
||
436 | * @api |
||
437 | * |
||
438 | * @return string |
||
439 | */ |
||
440 | public function getOmsCaptureEventName() |
||
441 | { |
||
442 | return static::COMPUTOP_OMS_EVENT_CAPTURE; |
||
443 | } |
||
444 | |||
445 | /** |
||
446 | * @api |
||
447 | * |
||
448 | * @return string[] |
||
449 | */ |
||
450 | public function getCrifGreenPaymentMethods(): array |
||
451 | { |
||
452 | return $this->get(ComputopConstants::CRIF_GREEN_AVAILABLE_PAYMENT_METHODS); |
||
453 | } |
||
454 | |||
455 | /** |
||
456 | * @api |
||
457 | * |
||
458 | * @return string[] |
||
459 | */ |
||
460 | public function getCrifYellowPaymentMethods(): array |
||
461 | { |
||
462 | return $this->get(ComputopConstants::CRIF_YELLOW_AVAILABLE_PAYMENT_METHODS); |
||
463 | } |
||
464 | |||
465 | /** |
||
466 | * @api |
||
467 | * |
||
468 | * @return string[] |
||
469 | */ |
||
470 | public function getCrifRedPaymentMethods(): array |
||
471 | { |
||
472 | return $this->get(ComputopConstants::CRIF_RED_AVAILABLE_PAYMENT_METHODS); |
||
473 | } |
||
474 | |||
475 | /** |
||
476 | * @api |
||
477 | * |
||
478 | * @return bool |
||
479 | */ |
||
480 | public function isCrifEnabled(): bool |
||
481 | { |
||
482 | return (bool)$this->get(ComputopConstants::CRIF_ENABLED); |
||
483 | } |
||
484 | |||
485 | /** |
||
486 | * @api |
||
487 | * |
||
488 | * @return string |
||
489 | */ |
||
490 | public function getEtiId(): string |
||
491 | { |
||
492 | return SharedComputopConfig::COMPUTOP_MODULE_VERSION; |
||
493 | } |
||
494 | |||
495 | /** |
||
496 | * @api |
||
497 | * |
||
498 | * @return string |
||
499 | */ |
||
500 | public function getIdealIssuerId(): string |
||
503 | } |
||
504 | |||
505 | /** |
||
506 | * Specification: |
||
507 | * - Get Available currency for specific payment methods. |
||
508 | * |
||
509 | * @api |
||
510 | * |
||
511 | * @return array |
||
512 | */ |
||
513 | public function getComputopPaymentMethodCurrencyFilterMap(): array |
||
514 | { |
||
515 | return [ |
||
516 | SharedComputopConfig::PAYMENT_METHOD_PAYU_CEE_SINGLE => [ |
||
517 | 'PLN', |
||
518 | 'CZK', |
||
519 | ], |
||
520 | ]; |
||
521 | } |
||
522 | } |
||
523 |