Complex classes like AdyenApiBusinessFactory 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 AdyenApiBusinessFactory, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
55 | class AdyenApiBusinessFactory extends AbstractBusinessFactory |
||
56 | { |
||
57 | /** |
||
58 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
59 | */ |
||
60 | public function createGetPaymentMethodsRequest(): AdyenApiRequestInterface |
||
69 | |||
70 | /** |
||
71 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
72 | */ |
||
73 | public function createMakePaymentRequest(): AdyenApiRequestInterface |
||
82 | |||
83 | /** |
||
84 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
85 | */ |
||
86 | public function createPaymentDetailsRequest(): AdyenApiRequestInterface |
||
87 | { |
||
88 | return new AdyenApiRequest( |
||
89 | $this->createPaymentDetailsAdapter(), |
||
90 | $this->createPaymentDetailsConverter(), |
||
91 | $this->createPaymentDetailsMapper(), |
||
92 | $this->getConfig() |
||
93 | ); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
98 | */ |
||
99 | public function createAuthorizeRequest(): AdyenApiRequestInterface |
||
108 | |||
109 | /** |
||
110 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
111 | */ |
||
112 | public function createAuthorize3dRequest(): AdyenApiRequestInterface |
||
121 | |||
122 | /** |
||
123 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
124 | */ |
||
125 | public function createCaptureRequest(): AdyenApiRequestInterface |
||
134 | |||
135 | /** |
||
136 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
137 | */ |
||
138 | public function createCancelRequest(): AdyenApiRequestInterface |
||
147 | |||
148 | /** |
||
149 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
150 | */ |
||
151 | public function createRefundRequest(): AdyenApiRequestInterface |
||
160 | |||
161 | /** |
||
162 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
163 | */ |
||
164 | public function createCancelOrRefundRequest(): AdyenApiRequestInterface |
||
173 | |||
174 | /** |
||
175 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
176 | */ |
||
177 | public function createTechnicalCancelRequest(): AdyenApiRequestInterface |
||
186 | |||
187 | /** |
||
188 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
189 | */ |
||
190 | public function createAdjustAuthorizationRequest(): AdyenApiRequestInterface |
||
199 | |||
200 | /** |
||
201 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
202 | */ |
||
203 | public function createGetPaymentMethodsAdapter(): AdyenApiAdapterInterface |
||
210 | |||
211 | /** |
||
212 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
213 | */ |
||
214 | public function createMakePaymentAdapter(): AdyenApiAdapterInterface |
||
221 | |||
222 | /** |
||
223 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
224 | */ |
||
225 | public function createPaymentDetailsAdapter(): AdyenApiAdapterInterface |
||
226 | { |
||
227 | return new PaymentDetailsAdapter( |
||
228 | $this->getConfig(), |
||
229 | $this->getUtilEncodingService() |
||
230 | ); |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
235 | */ |
||
236 | public function createAuthorizeAdapter(): AdyenApiAdapterInterface |
||
243 | |||
244 | /** |
||
245 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
246 | */ |
||
247 | public function createAuthorize3dAdapter(): AdyenApiAdapterInterface |
||
254 | |||
255 | /** |
||
256 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
257 | */ |
||
258 | public function createCaptureAdapter(): AdyenApiAdapterInterface |
||
265 | |||
266 | /** |
||
267 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
268 | */ |
||
269 | public function createCancelAdapter(): AdyenApiAdapterInterface |
||
276 | |||
277 | /** |
||
278 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
279 | */ |
||
280 | public function createRefundAdapter(): AdyenApiAdapterInterface |
||
287 | |||
288 | /** |
||
289 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
290 | */ |
||
291 | public function createCancelOrRefundAdapter(): AdyenApiAdapterInterface |
||
298 | |||
299 | /** |
||
300 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
301 | */ |
||
302 | public function createTechnicalCancelAdapter(): AdyenApiAdapterInterface |
||
309 | |||
310 | /** |
||
311 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
312 | */ |
||
313 | public function createAdjustAuthorizationAdapter(): AdyenApiAdapterInterface |
||
320 | |||
321 | /** |
||
322 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
323 | */ |
||
324 | public function createGetPaymentMethodsConverter(): AdyenApiConverterInterface |
||
331 | |||
332 | /** |
||
333 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
334 | */ |
||
335 | public function createMakePaymentConverter(): AdyenApiConverterInterface |
||
342 | |||
343 | /** |
||
344 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
345 | */ |
||
346 | public function createPaymentDetailsConverter(): AdyenApiConverterInterface |
||
347 | { |
||
348 | return new PaymentDetailsConverter( |
||
349 | $this->getConfig(), |
||
350 | $this->getUtilEncodingService() |
||
351 | ); |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
356 | */ |
||
357 | public function createAuthorizeConverter(): AdyenApiConverterInterface |
||
364 | |||
365 | /** |
||
366 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
367 | */ |
||
368 | public function createAuthorize3dConverter(): AdyenApiConverterInterface |
||
375 | |||
376 | /** |
||
377 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
378 | */ |
||
379 | public function createCaptureConverter(): AdyenApiConverterInterface |
||
386 | |||
387 | /** |
||
388 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
389 | */ |
||
390 | public function createCancelConverter(): AdyenApiConverterInterface |
||
397 | |||
398 | /** |
||
399 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
400 | */ |
||
401 | public function createRefundConverter(): AdyenApiConverterInterface |
||
408 | |||
409 | /** |
||
410 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
411 | */ |
||
412 | public function createCancelOrRefundConverter(): AdyenApiConverterInterface |
||
419 | |||
420 | /** |
||
421 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
422 | */ |
||
423 | public function createTechnicalCancelConverter(): AdyenApiConverterInterface |
||
430 | |||
431 | /** |
||
432 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
433 | */ |
||
434 | public function createAdjustAuthorizationConverter(): AdyenApiConverterInterface |
||
441 | |||
442 | /** |
||
443 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
444 | */ |
||
445 | public function createGetPaymentMethodsMapper(): AdyenApiMapperInterface |
||
449 | |||
450 | /** |
||
451 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
452 | */ |
||
453 | public function createMakePaymentMapper(): AdyenApiMapperInterface |
||
457 | |||
458 | /** |
||
459 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
460 | */ |
||
461 | public function createPaymentDetailsMapper(): AdyenApiMapperInterface |
||
462 | { |
||
463 | return new PaymentDetailsMapper($this->getConfig()); |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
468 | */ |
||
469 | public function createAuthorizeMapper(): AdyenApiMapperInterface |
||
473 | |||
474 | /** |
||
475 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
476 | */ |
||
477 | public function createAuthorize3dMapper(): AdyenApiMapperInterface |
||
481 | |||
482 | /** |
||
483 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
484 | */ |
||
485 | public function createCaptureMapper(): AdyenApiMapperInterface |
||
489 | |||
490 | /** |
||
491 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
492 | */ |
||
493 | public function createCancelMapper(): AdyenApiMapperInterface |
||
497 | |||
498 | /** |
||
499 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
500 | */ |
||
501 | public function createRefundMapper(): AdyenApiMapperInterface |
||
505 | |||
506 | /** |
||
507 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
508 | */ |
||
509 | public function createCancelOrRefundMapper(): AdyenApiMapperInterface |
||
513 | |||
514 | /** |
||
515 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
516 | */ |
||
517 | public function createTechnicalCancelMapper(): AdyenApiMapperInterface |
||
521 | |||
522 | /** |
||
523 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
524 | */ |
||
525 | public function createAdjustAuthorizationMapper(): AdyenApiMapperInterface |
||
529 | |||
530 | /** |
||
531 | * @return \SprykerEco\Zed\AdyenApi\Dependency\Service\AdyenApiToUtilEncodingServiceInterface |
||
532 | */ |
||
533 | public function getUtilEncodingService(): AdyenApiToUtilEncodingServiceInterface |
||
537 | } |
||
538 |