Total Complexity | 55 |
Total Lines | 535 |
Duplicated Lines | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 0 |
Complex classes like ComputopBusinessFactory 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 ComputopBusinessFactory, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
90 | class ComputopBusinessFactory extends AbstractBusinessFactory |
||
91 | { |
||
92 | /** |
||
93 | * @return \SprykerEco\Zed\Computop\Business\Order\OrderManagerInterface |
||
94 | */ |
||
95 | public function createOrderSaver(): OrderManagerInterface |
||
96 | { |
||
97 | $orderSaver = new OrderManager($this->getConfig()); |
||
98 | |||
99 | $orderSaver->registerMapper($this->createOrderFactory()->createInitCreditCardMapper()); |
||
100 | $orderSaver->registerMapper($this->createOrderFactory()->createInitPayNowMapper()); |
||
101 | $orderSaver->registerMapper($this->createOrderFactory()->createInitPayPalMapper()); |
||
102 | $orderSaver->registerMapper($this->createOrderFactory()->createInitDirectDebitMapper()); |
||
103 | $orderSaver->registerMapper($this->createOrderFactory()->createInitSofortMapper()); |
||
104 | $orderSaver->registerMapper($this->createOrderFactory()->createInitPaydirektMapper()); |
||
105 | $orderSaver->registerMapper($this->createOrderFactory()->createInitIdealMapper()); |
||
106 | $orderSaver->registerMapper($this->createOrderFactory()->createInitEasyCreditMapper()); |
||
107 | $orderSaver->registerMapper($this->createOrderFactory()->createPayuCeeSinglePostPlaceMapper()); |
||
108 | |||
109 | return $orderSaver; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @return \SprykerEco\Zed\Computop\Business\Hook\ComputopPostSaveHookInterface |
||
114 | */ |
||
115 | public function createPostSaveHook(): ComputopPostSaveHookInterface |
||
116 | { |
||
117 | $postSaveHook = new ComputopPostSaveHook($this->getConfig()); |
||
118 | $postSaveHook->registerMapper($this->createPostSaveSofortMapper()); |
||
119 | $postSaveHook->registerMapper($this->createPostSavePaydirektMapper()); |
||
120 | $postSaveHook->registerMapper($this->createPostSaveIdealMapper()); |
||
121 | $postSaveHook->registerMapper($this->createPostSaveCreditCart()); |
||
122 | $postSaveHook->registerMapper($this->createPostSavePayNowMapper()); |
||
123 | $postSaveHook->registerMapper($this->createPostSavePayPal()); |
||
124 | $postSaveHook->registerMapper($this->createPostSaveDirectDebit()); |
||
125 | $postSaveHook->registerMapper($this->createPostSaveEasyCredit()); |
||
126 | $postSaveHook->registerMapper($this->createInitPayuCeeSingleMapper()); |
||
127 | |||
128 | return $postSaveHook; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
133 | */ |
||
134 | public function createSofortResponseSaver(): InitResponseSaverInterface |
||
135 | { |
||
136 | return new SofortResponseSaver($this->getQueryContainer(), $this->getOmsFacade(), $this->getConfig()); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
141 | */ |
||
142 | public function createIdealResponseSaver(): InitResponseSaverInterface |
||
143 | { |
||
144 | return new IdealResponseSaver($this->getQueryContainer(), $this->getOmsFacade(), $this->getConfig()); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
149 | */ |
||
150 | public function createPaydirektResponseSaver(): InitResponseSaverInterface |
||
151 | { |
||
152 | return new PaydirektResponseSaver($this->getQueryContainer(), $this->getOmsFacade(), $this->getConfig()); |
||
153 | } |
||
154 | |||
155 | /** |
||
156 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
157 | */ |
||
158 | public function createCreditCardResponseSaver(): InitResponseSaverInterface |
||
159 | { |
||
160 | return new CreditCardResponseSaver($this->getQueryContainer(), $this->getOmsFacade(), $this->getConfig()); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
165 | */ |
||
166 | public function createPayNowResponseSaver(): InitResponseSaverInterface |
||
167 | { |
||
168 | return new PayNowResponseSaver($this->getQueryContainer(), $this->getOmsFacade(), $this->getConfig()); |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
173 | */ |
||
174 | public function createPayPalResponseSaver(): InitResponseSaverInterface |
||
175 | { |
||
176 | return new PayPalResponseSaver($this->getQueryContainer(), $this->getOmsFacade(), $this->getConfig()); |
||
177 | } |
||
178 | |||
179 | /** |
||
180 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
181 | */ |
||
182 | public function createDirectDebitResponseSaver(): InitResponseSaverInterface |
||
185 | } |
||
186 | |||
187 | /** |
||
188 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
189 | */ |
||
190 | public function createEasyCreditResponseSaver(): InitResponseSaverInterface |
||
191 | { |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\Init\InitResponseSaverInterface |
||
197 | */ |
||
198 | public function createPayuCeeSingleResponseSaver(): InitResponseSaverInterface |
||
199 | { |
||
200 | return new PayuCeeSingleResponseSaver( |
||
201 | $this->getQueryContainer(), |
||
202 | $this->getOmsFacade(), |
||
203 | $this->getConfig(), |
||
204 | $this->getEntityManager() |
||
205 | ); |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Logger\ComputopResponseLoggerInterface |
||
210 | */ |
||
211 | public function createComputopResponseLogger(): ComputopResponseLoggerInterface |
||
212 | { |
||
213 | return new ComputopResponseLogger(); |
||
214 | } |
||
215 | |||
216 | /** |
||
217 | * @return \SprykerEco\Zed\Computop\Dependency\ComputopToStoreInterface |
||
218 | */ |
||
219 | public function getStore(): ComputopToStoreInterface |
||
220 | { |
||
221 | return $this->getProvidedDependency(ComputopDependencyProvider::STORE); |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
226 | */ |
||
227 | public function createAuthorizeCommandHandler(): CommandHandlerInterface |
||
228 | { |
||
229 | return new AuthorizeCommandHandler( |
||
230 | $this->createAuthorizeHandler(), |
||
231 | $this->createAuthorizeManager() |
||
232 | ); |
||
233 | } |
||
234 | |||
235 | /** |
||
236 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
237 | */ |
||
238 | public function createCancelCommandHandler(): CommandHandlerInterface |
||
239 | { |
||
240 | return new CancelCommandHandler( |
||
241 | $this->createInquireHandler(), |
||
242 | $this->createReverseHandler(), |
||
243 | $this->createCancelManager(), |
||
244 | $this->getFlashMessengerFacade() |
||
245 | ); |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
250 | */ |
||
251 | public function createCaptureCommandHandler(): CommandHandlerInterface |
||
252 | { |
||
253 | return new CaptureCommandHandler( |
||
254 | $this->createCaptureHandler(), |
||
255 | $this->createCaptureManager() |
||
256 | ); |
||
257 | } |
||
258 | |||
259 | /** |
||
260 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
261 | */ |
||
262 | public function createRefundCommandHandler(): CommandHandlerInterface |
||
263 | { |
||
264 | return new RefundCommandHandler( |
||
265 | $this->createRefundHandler(), |
||
266 | $this->createRefundManager() |
||
267 | ); |
||
268 | } |
||
269 | |||
270 | /** |
||
271 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
272 | */ |
||
273 | public function createEasyCreditAuthorizeCommandHandler(): CommandHandlerInterface |
||
274 | { |
||
275 | return new AuthorizeCommandHandler( |
||
276 | $this->createEasyCreditAuthorizeHandler(), |
||
277 | $this->createAuthorizeManager() |
||
278 | ); |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PrePlace\PrePlaceHandlerInterface |
||
283 | */ |
||
284 | public function createEasyCreditStatusHandler(): PrePlaceHandlerInterface |
||
285 | { |
||
286 | return new EasyCreditStatusHandler( |
||
287 | $this->getComputopApiFacade(), |
||
288 | $this->getMoneyFacade(), |
||
289 | $this->createComputopResponseLogger() |
||
290 | ); |
||
291 | } |
||
292 | |||
293 | /** |
||
294 | * @return \SprykerEco\Zed\Computop\Business\RiskCheck\Handler\HandlerInterface |
||
295 | */ |
||
296 | public function createCrifHandler(): HandlerInterface |
||
297 | { |
||
298 | return new CrifHandler( |
||
299 | $this->getComputopApiFacade(), |
||
300 | $this->createCrifSaver(), |
||
301 | $this->getConfig() |
||
302 | ); |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @return \SprykerEco\Zed\Computop\Business\Logger\LoggerInterface |
||
307 | */ |
||
308 | public function createComputopLogger(): LoggerInterface |
||
309 | { |
||
310 | return new ComputopLogger(); |
||
311 | } |
||
312 | |||
313 | /** |
||
314 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
315 | */ |
||
316 | public function createEasyCreditAuthorizeHandler(): PostPlaceHandlerInterface |
||
317 | { |
||
318 | return new EasyCreditAuthorizeHandler( |
||
319 | $this->getComputopApiFacade(), |
||
320 | $this->createAuthorizeSaver() |
||
321 | ); |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * @return \SprykerEco\Zed\Computop\Business\Payment\Reader\ComputopPaymentReaderInterface |
||
326 | */ |
||
327 | public function createPaymentReader(): ComputopPaymentReaderInterface |
||
328 | { |
||
329 | return new ComputopPaymentReader($this->getQueryContainer()); |
||
330 | } |
||
331 | |||
332 | /** |
||
333 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
334 | */ |
||
335 | public function createAuthorizeHandler(): PostPlaceHandlerInterface |
||
336 | { |
||
337 | return new AuthorizeHandler( |
||
338 | $this->getComputopApiFacade(), |
||
339 | $this->createAuthorizeSaver() |
||
340 | ); |
||
341 | } |
||
342 | |||
343 | /** |
||
344 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
345 | */ |
||
346 | public function createReverseHandler(): PostPlaceHandlerInterface |
||
347 | { |
||
348 | return new ReverseHandler( |
||
349 | $this->getComputopApiFacade(), |
||
350 | $this->createReverseSaver() |
||
351 | ); |
||
352 | } |
||
353 | |||
354 | /** |
||
355 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
356 | */ |
||
357 | public function createInquireHandler(): PostPlaceHandlerInterface |
||
362 | ); |
||
363 | } |
||
364 | |||
365 | /** |
||
366 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
367 | */ |
||
368 | public function createCaptureHandler(): PostPlaceHandlerInterface |
||
373 | ); |
||
374 | } |
||
375 | |||
376 | /** |
||
377 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
378 | */ |
||
379 | public function createRefundHandler(): PostPlaceHandlerInterface |
||
380 | { |
||
381 | return new RefundHandler( |
||
382 | $this->getComputopApiFacade(), |
||
383 | $this->createRefundSaver() |
||
384 | ); |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * @return \SprykerEco\Zed\Computop\Business\RiskCheck\Saver\RiskCheckSaverInterface |
||
389 | */ |
||
390 | public function createCrifSaver(): RiskCheckSaverInterface |
||
391 | { |
||
392 | return new CrifSaver( |
||
393 | $this->getQueryContainer(), |
||
394 | $this->createComputopLogger(), |
||
395 | $this->getConfig() |
||
396 | ); |
||
397 | } |
||
398 | |||
399 | /** |
||
400 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
401 | */ |
||
402 | public function createAuthorizeSaver(): SaverInterface |
||
403 | { |
||
404 | return new AuthorizeSaver( |
||
405 | $this->getQueryContainer(), |
||
406 | $this->createComputopResponseLogger(), |
||
407 | $this->getConfig() |
||
408 | ); |
||
409 | } |
||
410 | |||
411 | /** |
||
412 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
413 | */ |
||
414 | public function createReverseSaver(): SaverInterface |
||
415 | { |
||
416 | return new ReverseSaver( |
||
417 | $this->getQueryContainer(), |
||
418 | $this->createComputopResponseLogger(), |
||
419 | $this->getConfig() |
||
420 | ); |
||
421 | } |
||
422 | |||
423 | /** |
||
424 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
425 | */ |
||
426 | public function createInquireSaver(): SaverInterface |
||
427 | { |
||
428 | return new InquireSaver( |
||
429 | $this->getQueryContainer(), |
||
430 | $this->createComputopResponseLogger(), |
||
431 | $this->getConfig() |
||
432 | ); |
||
433 | } |
||
434 | |||
435 | /** |
||
436 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
437 | */ |
||
438 | public function createCaptureSaver(): SaverInterface |
||
439 | { |
||
440 | return new CaptureSaver( |
||
441 | $this->getQueryContainer(), |
||
442 | $this->createComputopResponseLogger(), |
||
443 | $this->getConfig() |
||
444 | ); |
||
445 | } |
||
446 | |||
447 | /** |
||
448 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
449 | */ |
||
450 | public function createRefundSaver(): SaverInterface |
||
451 | { |
||
452 | return new RefundSaver( |
||
453 | $this->getQueryContainer(), |
||
454 | $this->createComputopResponseLogger(), |
||
455 | $this->getConfig() |
||
456 | ); |
||
457 | } |
||
458 | |||
459 | /** |
||
460 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface |
||
461 | */ |
||
462 | public function createAuthorizeManager(): ManagerInterface |
||
463 | { |
||
464 | return new AuthorizeManager($this->getQueryContainer(), $this->getConfig()); |
||
465 | } |
||
466 | |||
467 | /** |
||
468 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\CancelManagerInterface |
||
469 | */ |
||
470 | public function createCancelManager(): CancelManagerInterface |
||
471 | { |
||
472 | return new CancelManager($this->getQueryContainer(), $this->getConfig()); |
||
473 | } |
||
474 | |||
475 | /** |
||
476 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface |
||
477 | */ |
||
478 | public function createCaptureManager(): ManagerInterface |
||
479 | { |
||
480 | return new CaptureManager($this->getQueryContainer(), $this->getConfig()); |
||
481 | } |
||
482 | |||
483 | /** |
||
484 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface |
||
485 | */ |
||
486 | public function createRefundManager(): ManagerInterface |
||
487 | { |
||
488 | return new RefundManager($this->getQueryContainer(), $this->getConfig()); |
||
489 | } |
||
490 | |||
491 | /** |
||
492 | * @return \SprykerEco\Zed\Computop\Business\Order\ComputopBusinessOrderFactoryInterface |
||
493 | */ |
||
494 | public function createOrderFactory(): ComputopBusinessOrderFactoryInterface |
||
497 | } |
||
498 | |||
499 | /** |
||
500 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
501 | */ |
||
502 | public function createPostSaveSofortMapper(): InitMapperInterface |
||
503 | { |
||
504 | return new InitSofortMapper($this->getConfig(), $this->getComputopApiService()); |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
509 | */ |
||
510 | public function createPostSaveCreditCart(): InitMapperInterface |
||
511 | { |
||
512 | return new InitCreditCardMapper($this->getConfig(), $this->getComputopApiService()); |
||
513 | } |
||
514 | |||
515 | /** |
||
516 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
517 | */ |
||
518 | public function createPostSavePayNowMapper(): InitMapperInterface |
||
519 | { |
||
520 | return new InitPayNowMapper($this->getConfig(), $this->getComputopApiService()); |
||
521 | } |
||
522 | |||
523 | /** |
||
524 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
525 | */ |
||
526 | public function createPostSavePayPal(): InitMapperInterface |
||
527 | { |
||
528 | return new InitPayPalMapper($this->getConfig(), $this->getComputopApiService()); |
||
529 | } |
||
530 | |||
531 | /** |
||
532 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
533 | */ |
||
534 | public function createPostSaveDirectDebit(): InitMapperInterface |
||
537 | } |
||
538 | |||
539 | /** |
||
540 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
541 | */ |
||
542 | public function createPostSaveEasyCredit(): InitMapperInterface |
||
545 | } |
||
546 | |||
547 | /** |
||
548 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
549 | */ |
||
550 | public function createPostSavePaydirektMapper(): InitMapperInterface |
||
551 | { |
||
552 | return new InitPaydirektMapper($this->getConfig(), $this->getComputopApiService()); |
||
553 | } |
||
554 | |||
555 | /** |
||
556 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
557 | */ |
||
558 | public function createInitPayuCeeSingleMapper(): InitMapperInterface |
||
559 | { |
||
560 | return new InitPayuCeeSingleMapper($this->getConfig(), $this->getComputopApiService()); |
||
561 | } |
||
562 | |||
563 | /** |
||
564 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
565 | */ |
||
566 | public function createPostSaveIdealMapper(): InitMapperInterface |
||
567 | { |
||
568 | return new InitIdealMapper($this->getConfig(), $this->getComputopApiService()); |
||
569 | } |
||
570 | |||
571 | /** |
||
572 | * @return \SprykerEco\Zed\Computop\Business\Payment\PaymentMethodFilterInterface |
||
573 | */ |
||
574 | public function createPaymentMethodFilter(): PaymentMethodFilterInterface |
||
575 | { |
||
576 | return new PaymentMethodFilter($this->getConfig()); |
||
577 | } |
||
578 | |||
579 | /** |
||
580 | * @return \SprykerEco\Zed\Computop\Business\Processor\NotificationProcessorInterface |
||
581 | */ |
||
582 | public function createNotificationProcessor(): NotificationProcessorInterface |
||
585 | } |
||
586 | |||
587 | /** |
||
588 | * @return \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface |
||
589 | */ |
||
590 | public function getComputopApiService(): ComputopApiServiceInterface |
||
591 | { |
||
592 | return $this->getProvidedDependency(ComputopDependencyProvider::SERVICE_COMPUTOP_API); |
||
593 | } |
||
594 | |||
595 | /** |
||
596 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface |
||
597 | */ |
||
598 | public function getOmsFacade(): ComputopToOmsFacadeInterface |
||
601 | } |
||
602 | |||
603 | /** |
||
604 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToMessengerFacadeInterface |
||
605 | */ |
||
606 | public function getFlashMessengerFacade(): ComputopToMessengerFacadeInterface |
||
609 | } |
||
610 | |||
611 | /** |
||
612 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToMoneyFacadeInterface |
||
613 | */ |
||
614 | public function getMoneyFacade(): ComputopToMoneyFacadeInterface |
||
617 | } |
||
618 | |||
619 | /** |
||
620 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToComputopApiFacadeInterface |
||
621 | */ |
||
622 | public function getComputopApiFacade(): ComputopToComputopApiFacadeInterface |
||
627 |