Total Complexity | 45 |
Total Lines | 481 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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.
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 |
||
61 | { |
||
62 | return new AdyenApiRequest( |
||
63 | $this->createGetPaymentMethodsAdapter(), |
||
64 | $this->createGetPaymentMethodsConverter(), |
||
65 | $this->createGetPaymentMethodsMapper(), |
||
66 | $this->getConfig() |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
72 | */ |
||
73 | public function createMakePaymentRequest(): AdyenApiRequestInterface |
||
74 | { |
||
75 | return new AdyenApiRequest( |
||
76 | $this->createMakePaymentAdapter(), |
||
77 | $this->createMakePaymentConverter(), |
||
78 | $this->createMakePaymentMapper(), |
||
79 | $this->getConfig() |
||
80 | ); |
||
81 | } |
||
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 |
||
100 | { |
||
101 | return new AdyenApiRequest( |
||
102 | $this->createAuthorizeAdapter(), |
||
103 | $this->createAuthorizeConverter(), |
||
104 | $this->createAuthorizeMapper(), |
||
105 | $this->getConfig() |
||
106 | ); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
111 | */ |
||
112 | public function createAuthorize3dRequest(): AdyenApiRequestInterface |
||
113 | { |
||
114 | return new AdyenApiRequest( |
||
115 | $this->createAuthorize3dAdapter(), |
||
116 | $this->createAuthorize3dConverter(), |
||
117 | $this->createAuthorize3dMapper(), |
||
118 | $this->getConfig() |
||
119 | ); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
124 | */ |
||
125 | public function createCaptureRequest(): AdyenApiRequestInterface |
||
126 | { |
||
127 | return new AdyenApiRequest( |
||
128 | $this->createCaptureAdapter(), |
||
129 | $this->createCaptureConverter(), |
||
130 | $this->createCaptureMapper(), |
||
131 | $this->getConfig() |
||
132 | ); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
137 | */ |
||
138 | public function createCancelRequest(): AdyenApiRequestInterface |
||
139 | { |
||
140 | return new AdyenApiRequest( |
||
141 | $this->createCancelAdapter(), |
||
142 | $this->createCancelConverter(), |
||
143 | $this->createCancelMapper(), |
||
144 | $this->getConfig() |
||
145 | ); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
150 | */ |
||
151 | public function createRefundRequest(): AdyenApiRequestInterface |
||
152 | { |
||
153 | return new AdyenApiRequest( |
||
154 | $this->createRefundAdapter(), |
||
155 | $this->createRefundConverter(), |
||
156 | $this->createRefundMapper(), |
||
157 | $this->getConfig() |
||
158 | ); |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
163 | */ |
||
164 | public function createCancelOrRefundRequest(): AdyenApiRequestInterface |
||
165 | { |
||
166 | return new AdyenApiRequest( |
||
167 | $this->createCancelOrRefundAdapter(), |
||
168 | $this->createCancelOrRefundConverter(), |
||
169 | $this->createCancelOrRefundMapper(), |
||
170 | $this->getConfig() |
||
171 | ); |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
176 | */ |
||
177 | public function createTechnicalCancelRequest(): AdyenApiRequestInterface |
||
178 | { |
||
179 | return new AdyenApiRequest( |
||
180 | $this->createTechnicalCancelAdapter(), |
||
181 | $this->createTechnicalCancelConverter(), |
||
182 | $this->createTechnicalCancelMapper(), |
||
183 | $this->getConfig() |
||
184 | ); |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * @return \SprykerEco\Zed\AdyenApi\Business\Request\AdyenApiRequestInterface |
||
189 | */ |
||
190 | public function createAdjustAuthorizationRequest(): AdyenApiRequestInterface |
||
191 | { |
||
192 | return new AdyenApiRequest( |
||
193 | $this->createAdjustAuthorizationAdapter(), |
||
194 | $this->createAdjustAuthorizationConverter(), |
||
195 | $this->createAdjustAuthorizationMapper(), |
||
196 | $this->getConfig() |
||
197 | ); |
||
198 | } |
||
199 | |||
200 | /** |
||
201 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
202 | */ |
||
203 | public function createGetPaymentMethodsAdapter(): AdyenApiAdapterInterface |
||
208 | ); |
||
209 | } |
||
210 | |||
211 | /** |
||
212 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
213 | */ |
||
214 | public function createMakePaymentAdapter(): AdyenApiAdapterInterface |
||
215 | { |
||
216 | return new MakePaymentAdapter( |
||
217 | $this->getConfig(), |
||
218 | $this->getUtilEncodingService() |
||
219 | ); |
||
220 | } |
||
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 |
||
237 | { |
||
238 | return new AuthorizeAdapter( |
||
239 | $this->getConfig(), |
||
240 | $this->getUtilEncodingService() |
||
241 | ); |
||
242 | } |
||
243 | |||
244 | /** |
||
245 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
246 | */ |
||
247 | public function createAuthorize3dAdapter(): AdyenApiAdapterInterface |
||
248 | { |
||
249 | return new Authorize3dAdapter( |
||
250 | $this->getConfig(), |
||
251 | $this->getUtilEncodingService() |
||
252 | ); |
||
253 | } |
||
254 | |||
255 | /** |
||
256 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
257 | */ |
||
258 | public function createCaptureAdapter(): AdyenApiAdapterInterface |
||
259 | { |
||
260 | return new CaptureAdapter( |
||
261 | $this->getConfig(), |
||
262 | $this->getUtilEncodingService() |
||
263 | ); |
||
264 | } |
||
265 | |||
266 | /** |
||
267 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
268 | */ |
||
269 | public function createCancelAdapter(): AdyenApiAdapterInterface |
||
270 | { |
||
271 | return new CancelAdapter( |
||
272 | $this->getConfig(), |
||
273 | $this->getUtilEncodingService() |
||
274 | ); |
||
275 | } |
||
276 | |||
277 | /** |
||
278 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
279 | */ |
||
280 | public function createRefundAdapter(): AdyenApiAdapterInterface |
||
281 | { |
||
282 | return new RefundAdapter( |
||
283 | $this->getConfig(), |
||
284 | $this->getUtilEncodingService() |
||
285 | ); |
||
286 | } |
||
287 | |||
288 | /** |
||
289 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
290 | */ |
||
291 | public function createCancelOrRefundAdapter(): AdyenApiAdapterInterface |
||
292 | { |
||
293 | return new CancelOrRefundAdapter( |
||
294 | $this->getConfig(), |
||
295 | $this->getUtilEncodingService() |
||
296 | ); |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
301 | */ |
||
302 | public function createTechnicalCancelAdapter(): AdyenApiAdapterInterface |
||
303 | { |
||
304 | return new TechnicalCancelAdapter( |
||
305 | $this->getConfig(), |
||
306 | $this->getUtilEncodingService() |
||
307 | ); |
||
308 | } |
||
309 | |||
310 | /** |
||
311 | * @return \SprykerEco\Zed\AdyenApi\Business\Adapter\AdyenApiAdapterInterface |
||
312 | */ |
||
313 | public function createAdjustAuthorizationAdapter(): AdyenApiAdapterInterface |
||
314 | { |
||
315 | return new AdjustAuthorizationAdapter( |
||
316 | $this->getConfig(), |
||
317 | $this->getUtilEncodingService() |
||
318 | ); |
||
319 | } |
||
320 | |||
321 | /** |
||
322 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
323 | */ |
||
324 | public function createGetPaymentMethodsConverter(): AdyenApiConverterInterface |
||
325 | { |
||
326 | return new GetPaymentMethodsConverter( |
||
327 | $this->getConfig(), |
||
328 | $this->getUtilEncodingService() |
||
329 | ); |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
334 | */ |
||
335 | public function createMakePaymentConverter(): AdyenApiConverterInterface |
||
336 | { |
||
337 | return new MakePaymentConverter( |
||
338 | $this->getConfig(), |
||
339 | $this->getUtilEncodingService() |
||
340 | ); |
||
341 | } |
||
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 |
||
358 | { |
||
359 | return new AuthorizeConverter( |
||
360 | $this->getConfig(), |
||
361 | $this->getUtilEncodingService() |
||
362 | ); |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
367 | */ |
||
368 | public function createAuthorize3dConverter(): AdyenApiConverterInterface |
||
369 | { |
||
370 | return new Authorize3dConverter( |
||
371 | $this->getConfig(), |
||
372 | $this->getUtilEncodingService() |
||
373 | ); |
||
374 | } |
||
375 | |||
376 | /** |
||
377 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
378 | */ |
||
379 | public function createCaptureConverter(): AdyenApiConverterInterface |
||
380 | { |
||
381 | return new CaptureConverter( |
||
382 | $this->getConfig(), |
||
383 | $this->getUtilEncodingService() |
||
384 | ); |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
389 | */ |
||
390 | public function createCancelConverter(): AdyenApiConverterInterface |
||
391 | { |
||
392 | return new CancelConverter( |
||
393 | $this->getConfig(), |
||
394 | $this->getUtilEncodingService() |
||
395 | ); |
||
396 | } |
||
397 | |||
398 | /** |
||
399 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
400 | */ |
||
401 | public function createRefundConverter(): AdyenApiConverterInterface |
||
402 | { |
||
403 | return new RefundConverter( |
||
404 | $this->getConfig(), |
||
405 | $this->getUtilEncodingService() |
||
406 | ); |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
411 | */ |
||
412 | public function createCancelOrRefundConverter(): AdyenApiConverterInterface |
||
413 | { |
||
414 | return new CancelOrRefundConverter( |
||
415 | $this->getConfig(), |
||
416 | $this->getUtilEncodingService() |
||
417 | ); |
||
418 | } |
||
419 | |||
420 | /** |
||
421 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
422 | */ |
||
423 | public function createTechnicalCancelConverter(): AdyenApiConverterInterface |
||
424 | { |
||
425 | return new TechnicalCancelConverter( |
||
426 | $this->getConfig(), |
||
427 | $this->getUtilEncodingService() |
||
428 | ); |
||
429 | } |
||
430 | |||
431 | /** |
||
432 | * @return \SprykerEco\Zed\AdyenApi\Business\Converter\AdyenApiConverterInterface |
||
433 | */ |
||
434 | public function createAdjustAuthorizationConverter(): AdyenApiConverterInterface |
||
439 | ); |
||
440 | } |
||
441 | |||
442 | /** |
||
443 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
444 | */ |
||
445 | public function createGetPaymentMethodsMapper(): AdyenApiMapperInterface |
||
446 | { |
||
447 | return new GetPaymentMethodsMapper($this->getConfig()); |
||
448 | } |
||
449 | |||
450 | /** |
||
451 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
452 | */ |
||
453 | public function createMakePaymentMapper(): AdyenApiMapperInterface |
||
454 | { |
||
455 | return new MakePaymentMapper($this->getConfig()); |
||
456 | } |
||
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 |
||
472 | } |
||
473 | |||
474 | /** |
||
475 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
476 | */ |
||
477 | public function createAuthorize3dMapper(): AdyenApiMapperInterface |
||
478 | { |
||
479 | return new Authorize3dMapper($this->getConfig()); |
||
480 | } |
||
481 | |||
482 | /** |
||
483 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
484 | */ |
||
485 | public function createCaptureMapper(): AdyenApiMapperInterface |
||
486 | { |
||
487 | return new CaptureMapper($this->getConfig()); |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
492 | */ |
||
493 | public function createCancelMapper(): AdyenApiMapperInterface |
||
494 | { |
||
495 | return new CancelMapper($this->getConfig()); |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
500 | */ |
||
501 | public function createRefundMapper(): AdyenApiMapperInterface |
||
502 | { |
||
503 | return new RefundMapper($this->getConfig()); |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
508 | */ |
||
509 | public function createCancelOrRefundMapper(): AdyenApiMapperInterface |
||
510 | { |
||
511 | return new CancelOrRefundMapper($this->getConfig()); |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
516 | */ |
||
517 | public function createTechnicalCancelMapper(): AdyenApiMapperInterface |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * @return \SprykerEco\Zed\AdyenApi\Business\Mapper\AdyenApiMapperInterface |
||
524 | */ |
||
525 | public function createAdjustAuthorizationMapper(): AdyenApiMapperInterface |
||
528 | } |
||
529 | |||
530 | /** |
||
531 | * @return \SprykerEco\Zed\AdyenApi\Dependency\Service\AdyenApiToUtilEncodingServiceInterface |
||
532 | */ |
||
533 | public function getUtilEncodingService(): AdyenApiToUtilEncodingServiceInterface |
||
534 | { |
||
535 | return $this->getProvidedDependency(AdyenApiDependencyProvider::SERVICE_UTIL_ENCODING); |
||
536 | } |
||
537 | } |
||
538 |