Total Complexity | 55 |
Total Lines | 534 |
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()->createInitPayuCeeSingleMapper()); |
||
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->createPostSavePayuCeeSingleMapper()); |
||
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 | ); |
||
205 | } |
||
206 | |||
207 | /** |
||
208 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Logger\ComputopResponseLoggerInterface |
||
209 | */ |
||
210 | public function createComputopResponseLogger(): ComputopResponseLoggerInterface |
||
211 | { |
||
212 | return new ComputopResponseLogger(); |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * @return \SprykerEco\Zed\Computop\Dependency\ComputopToStoreInterface |
||
217 | */ |
||
218 | public function getStore(): ComputopToStoreInterface |
||
219 | { |
||
220 | return $this->getProvidedDependency(ComputopDependencyProvider::STORE); |
||
221 | } |
||
222 | |||
223 | /** |
||
224 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
225 | */ |
||
226 | public function createAuthorizeCommandHandler(): CommandHandlerInterface |
||
227 | { |
||
228 | return new AuthorizeCommandHandler( |
||
229 | $this->createAuthorizeHandler(), |
||
230 | $this->createAuthorizeManager() |
||
231 | ); |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
236 | */ |
||
237 | public function createCancelCommandHandler(): CommandHandlerInterface |
||
238 | { |
||
239 | return new CancelCommandHandler( |
||
240 | $this->createInquireHandler(), |
||
241 | $this->createReverseHandler(), |
||
242 | $this->createCancelManager(), |
||
243 | $this->getFlashMessengerFacade() |
||
244 | ); |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
249 | */ |
||
250 | public function createCaptureCommandHandler(): CommandHandlerInterface |
||
251 | { |
||
252 | return new CaptureCommandHandler( |
||
253 | $this->createCaptureHandler(), |
||
254 | $this->createCaptureManager() |
||
255 | ); |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
260 | */ |
||
261 | public function createRefundCommandHandler(): CommandHandlerInterface |
||
262 | { |
||
263 | return new RefundCommandHandler( |
||
264 | $this->createRefundHandler(), |
||
265 | $this->createRefundManager() |
||
266 | ); |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\CommandHandlerInterface |
||
271 | */ |
||
272 | public function createEasyCreditAuthorizeCommandHandler(): CommandHandlerInterface |
||
273 | { |
||
274 | return new AuthorizeCommandHandler( |
||
275 | $this->createEasyCreditAuthorizeHandler(), |
||
276 | $this->createAuthorizeManager() |
||
277 | ); |
||
278 | } |
||
279 | |||
280 | /** |
||
281 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PrePlace\PrePlaceHandlerInterface |
||
282 | */ |
||
283 | public function createEasyCreditStatusHandler(): PrePlaceHandlerInterface |
||
284 | { |
||
285 | return new EasyCreditStatusHandler( |
||
286 | $this->getComputopApiFacade(), |
||
287 | $this->getMoneyFacade(), |
||
288 | $this->createComputopResponseLogger() |
||
289 | ); |
||
290 | } |
||
291 | |||
292 | /** |
||
293 | * @return \SprykerEco\Zed\Computop\Business\RiskCheck\Handler\HandlerInterface |
||
294 | */ |
||
295 | public function createCrifHandler(): HandlerInterface |
||
296 | { |
||
297 | return new CrifHandler( |
||
298 | $this->getComputopApiFacade(), |
||
299 | $this->createCrifSaver(), |
||
300 | $this->getConfig() |
||
301 | ); |
||
302 | } |
||
303 | |||
304 | /** |
||
305 | * @return \SprykerEco\Zed\Computop\Business\Logger\LoggerInterface |
||
306 | */ |
||
307 | public function createComputopLogger(): LoggerInterface |
||
308 | { |
||
309 | return new ComputopLogger(); |
||
310 | } |
||
311 | |||
312 | /** |
||
313 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
314 | */ |
||
315 | public function createEasyCreditAuthorizeHandler(): PostPlaceHandlerInterface |
||
316 | { |
||
317 | return new EasyCreditAuthorizeHandler( |
||
318 | $this->getComputopApiFacade(), |
||
319 | $this->createAuthorizeSaver() |
||
320 | ); |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @return \SprykerEco\Zed\Computop\Business\Payment\Reader\ComputopPaymentReaderInterface |
||
325 | */ |
||
326 | public function createPaymentReader(): ComputopPaymentReaderInterface |
||
327 | { |
||
328 | return new ComputopPaymentReader($this->getQueryContainer()); |
||
329 | } |
||
330 | |||
331 | /** |
||
332 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
333 | */ |
||
334 | public function createAuthorizeHandler(): PostPlaceHandlerInterface |
||
335 | { |
||
336 | return new AuthorizeHandler( |
||
337 | $this->getComputopApiFacade(), |
||
338 | $this->createAuthorizeSaver() |
||
339 | ); |
||
340 | } |
||
341 | |||
342 | /** |
||
343 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
344 | */ |
||
345 | public function createReverseHandler(): PostPlaceHandlerInterface |
||
346 | { |
||
347 | return new ReverseHandler( |
||
348 | $this->getComputopApiFacade(), |
||
349 | $this->createReverseSaver() |
||
350 | ); |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
355 | */ |
||
356 | public function createInquireHandler(): PostPlaceHandlerInterface |
||
361 | ); |
||
362 | } |
||
363 | |||
364 | /** |
||
365 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
366 | */ |
||
367 | public function createCaptureHandler(): PostPlaceHandlerInterface |
||
372 | ); |
||
373 | } |
||
374 | |||
375 | /** |
||
376 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\PostPlace\HandlerInterface |
||
377 | */ |
||
378 | public function createRefundHandler(): PostPlaceHandlerInterface |
||
379 | { |
||
380 | return new RefundHandler( |
||
381 | $this->getComputopApiFacade(), |
||
382 | $this->createRefundSaver() |
||
383 | ); |
||
384 | } |
||
385 | |||
386 | /** |
||
387 | * @return \SprykerEco\Zed\Computop\Business\RiskCheck\Saver\RiskCheckSaverInterface |
||
388 | */ |
||
389 | public function createCrifSaver(): RiskCheckSaverInterface |
||
390 | { |
||
391 | return new CrifSaver( |
||
392 | $this->getQueryContainer(), |
||
393 | $this->createComputopLogger(), |
||
394 | $this->getConfig() |
||
395 | ); |
||
396 | } |
||
397 | |||
398 | /** |
||
399 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
400 | */ |
||
401 | public function createAuthorizeSaver(): SaverInterface |
||
402 | { |
||
403 | return new AuthorizeSaver( |
||
404 | $this->getQueryContainer(), |
||
405 | $this->createComputopResponseLogger(), |
||
406 | $this->getConfig() |
||
407 | ); |
||
408 | } |
||
409 | |||
410 | /** |
||
411 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
412 | */ |
||
413 | public function createReverseSaver(): SaverInterface |
||
414 | { |
||
415 | return new ReverseSaver( |
||
416 | $this->getQueryContainer(), |
||
417 | $this->createComputopResponseLogger(), |
||
418 | $this->getConfig() |
||
419 | ); |
||
420 | } |
||
421 | |||
422 | /** |
||
423 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
424 | */ |
||
425 | public function createInquireSaver(): SaverInterface |
||
426 | { |
||
427 | return new InquireSaver( |
||
428 | $this->getQueryContainer(), |
||
429 | $this->createComputopResponseLogger(), |
||
430 | $this->getConfig() |
||
431 | ); |
||
432 | } |
||
433 | |||
434 | /** |
||
435 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
436 | */ |
||
437 | public function createCaptureSaver(): SaverInterface |
||
438 | { |
||
439 | return new CaptureSaver( |
||
440 | $this->getQueryContainer(), |
||
441 | $this->createComputopResponseLogger(), |
||
442 | $this->getConfig() |
||
443 | ); |
||
444 | } |
||
445 | |||
446 | /** |
||
447 | * @return \SprykerEco\Zed\Computop\Business\Payment\Handler\Saver\SaverInterface |
||
448 | */ |
||
449 | public function createRefundSaver(): SaverInterface |
||
450 | { |
||
451 | return new RefundSaver( |
||
452 | $this->getQueryContainer(), |
||
453 | $this->createComputopResponseLogger(), |
||
454 | $this->getConfig() |
||
455 | ); |
||
456 | } |
||
457 | |||
458 | /** |
||
459 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface |
||
460 | */ |
||
461 | public function createAuthorizeManager(): ManagerInterface |
||
462 | { |
||
463 | return new AuthorizeManager($this->getQueryContainer(), $this->getConfig()); |
||
464 | } |
||
465 | |||
466 | /** |
||
467 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\CancelManagerInterface |
||
468 | */ |
||
469 | public function createCancelManager(): CancelManagerInterface |
||
470 | { |
||
471 | return new CancelManager($this->getQueryContainer(), $this->getConfig()); |
||
472 | } |
||
473 | |||
474 | /** |
||
475 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface |
||
476 | */ |
||
477 | public function createCaptureManager(): ManagerInterface |
||
478 | { |
||
479 | return new CaptureManager($this->getQueryContainer(), $this->getConfig()); |
||
480 | } |
||
481 | |||
482 | /** |
||
483 | * @return \SprykerEco\Zed\Computop\Business\Oms\Command\Manager\ManagerInterface |
||
484 | */ |
||
485 | public function createRefundManager(): ManagerInterface |
||
486 | { |
||
487 | return new RefundManager($this->getQueryContainer(), $this->getConfig()); |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * @return \SprykerEco\Zed\Computop\Business\Order\ComputopBusinessOrderFactoryInterface |
||
492 | */ |
||
493 | public function createOrderFactory(): ComputopBusinessOrderFactoryInterface |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
500 | */ |
||
501 | public function createPostSaveSofortMapper(): InitMapperInterface |
||
502 | { |
||
503 | return new InitSofortMapper($this->getConfig(), $this->getComputopApiService()); |
||
504 | } |
||
505 | |||
506 | /** |
||
507 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
508 | */ |
||
509 | public function createPostSaveCreditCart(): InitMapperInterface |
||
510 | { |
||
511 | return new InitCreditCardMapper($this->getConfig(), $this->getComputopApiService()); |
||
512 | } |
||
513 | |||
514 | /** |
||
515 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
516 | */ |
||
517 | public function createPostSavePayNowMapper(): InitMapperInterface |
||
518 | { |
||
519 | return new InitPayNowMapper($this->getConfig(), $this->getComputopApiService()); |
||
520 | } |
||
521 | |||
522 | /** |
||
523 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
524 | */ |
||
525 | public function createPostSavePayPal(): InitMapperInterface |
||
526 | { |
||
527 | return new InitPayPalMapper($this->getConfig(), $this->getComputopApiService()); |
||
528 | } |
||
529 | |||
530 | /** |
||
531 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
532 | */ |
||
533 | public function createPostSaveDirectDebit(): InitMapperInterface |
||
536 | } |
||
537 | |||
538 | /** |
||
539 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
540 | */ |
||
541 | public function createPostSaveEasyCredit(): InitMapperInterface |
||
544 | } |
||
545 | |||
546 | /** |
||
547 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
548 | */ |
||
549 | public function createPostSavePaydirektMapper(): InitMapperInterface |
||
550 | { |
||
551 | return new InitPaydirektMapper($this->getConfig(), $this->getComputopApiService()); |
||
552 | } |
||
553 | |||
554 | /** |
||
555 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
556 | */ |
||
557 | public function createPostSavePayuCeeSingleMapper(): InitMapperInterface |
||
558 | { |
||
559 | return new InitPayuCeeSingleMapper($this->getConfig(), $this->getComputopApiService()); |
||
560 | } |
||
561 | |||
562 | /** |
||
563 | * @return \SprykerEco\Zed\Computop\Business\Hook\Mapper\Init\InitMapperInterface |
||
564 | */ |
||
565 | public function createPostSaveIdealMapper(): InitMapperInterface |
||
566 | { |
||
567 | return new InitIdealMapper($this->getConfig(), $this->getComputopApiService()); |
||
568 | } |
||
569 | |||
570 | /** |
||
571 | * @return \SprykerEco\Zed\Computop\Business\Payment\PaymentMethodFilterInterface |
||
572 | */ |
||
573 | public function createPaymentMethodFilter(): PaymentMethodFilterInterface |
||
574 | { |
||
575 | return new PaymentMethodFilter($this->getConfig()); |
||
576 | } |
||
577 | |||
578 | /** |
||
579 | * @return \SprykerEco\Zed\Computop\Business\Processor\NotificationProcessorInterface |
||
580 | */ |
||
581 | public function createNotificationProcessor(): NotificationProcessorInterface |
||
584 | } |
||
585 | |||
586 | /** |
||
587 | * @return \SprykerEco\Service\ComputopApi\ComputopApiServiceInterface |
||
588 | */ |
||
589 | public function getComputopApiService(): ComputopApiServiceInterface |
||
590 | { |
||
591 | return $this->getProvidedDependency(ComputopDependencyProvider::SERVICE_COMPUTOP_API); |
||
592 | } |
||
593 | |||
594 | /** |
||
595 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToOmsFacadeInterface |
||
596 | */ |
||
597 | public function getOmsFacade(): ComputopToOmsFacadeInterface |
||
600 | } |
||
601 | |||
602 | /** |
||
603 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToMessengerFacadeInterface |
||
604 | */ |
||
605 | public function getFlashMessengerFacade(): ComputopToMessengerFacadeInterface |
||
608 | } |
||
609 | |||
610 | /** |
||
611 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToMoneyFacadeInterface |
||
612 | */ |
||
613 | public function getMoneyFacade(): ComputopToMoneyFacadeInterface |
||
616 | } |
||
617 | |||
618 | /** |
||
619 | * @return \SprykerEco\Zed\Computop\Dependency\Facade\ComputopToComputopApiFacadeInterface |
||
620 | */ |
||
621 | public function getComputopApiFacade(): ComputopToComputopApiFacadeInterface |
||
626 |