Total Complexity | 47 |
Total Lines | 473 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like CrefoPayBusinessFactory 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 CrefoPayBusinessFactory, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
82 | class CrefoPayBusinessFactory extends AbstractBusinessFactory |
||
83 | { |
||
84 | /** |
||
85 | * @return \SprykerEco\Zed\CrefoPay\Business\Quote\Expander\CrefoPayQuoteExpanderInterface |
||
86 | */ |
||
87 | public function createQuoteExpander(): CrefoPayQuoteExpanderInterface |
||
88 | { |
||
89 | return new CrefoPayQuoteExpander( |
||
90 | $this->createQuoteExpanderMapper(), |
||
91 | $this->getCrefoPayApiFacade(), |
||
92 | ); |
||
93 | } |
||
94 | |||
95 | /** |
||
96 | * @return \SprykerEco\Zed\CrefoPay\Business\Quote\Expander\Mapper\CrefoPayQuoteExpanderMapperInterface |
||
97 | */ |
||
98 | public function createQuoteExpanderMapper(): CrefoPayQuoteExpanderMapperInterface |
||
99 | { |
||
100 | return new CrefoPayQuoteExpanderMapper( |
||
101 | $this->getCrefoPayService(), |
||
102 | $this->getUtilTextService(), |
||
103 | $this->getConfig(), |
||
104 | $this->getLocaleFacade(), |
||
105 | ); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @return \SprykerEco\Zed\CrefoPay\Business\Payment\Filter\CrefoPayPaymentMethodFilterInterface |
||
110 | */ |
||
111 | public function createPaymentMethodFilter(): CrefoPayPaymentMethodFilterInterface |
||
112 | { |
||
113 | return new CrefoPayPaymentMethodFilter( |
||
114 | $this->createCrefoPayPaymentMethodMapper(), |
||
115 | $this->getConfig(), |
||
116 | ); |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @return \SprykerEco\Zed\CrefoPay\Business\Processor\CrefoPayNotificationProcessorInterface |
||
121 | */ |
||
122 | public function createCrefoPayNotificationProcessor(): CrefoPayNotificationProcessorInterface |
||
123 | { |
||
124 | return new CrefoPayNotificationProcessor( |
||
125 | $this->createCrefoPayOmsStatusMapper(), |
||
126 | $this->createReader(), |
||
127 | $this->createWriter(), |
||
128 | ); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @return \SprykerEco\Zed\CrefoPay\Business\Mapper\OmsStatus\CrefoPayOmsStatusMapperInterface |
||
133 | */ |
||
134 | public function createCrefoPayOmsStatusMapper(): CrefoPayOmsStatusMapperInterface |
||
135 | { |
||
136 | return new CrefoPayOmsStatusMapper($this->getConfig()); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @return \SprykerEco\Zed\CrefoPay\Business\Payment\Saver\CrefoPayOrderPaymentSaverInterface |
||
141 | */ |
||
142 | public function createOrderPaymentSaver(): CrefoPayOrderPaymentSaverInterface |
||
143 | { |
||
144 | return new CrefoPayOrderPaymentSaver( |
||
145 | $this->createWriter(), |
||
146 | $this->getConfig(), |
||
147 | ); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @return \SprykerEco\Zed\CrefoPay\Business\Hook\Checkout\CrefoPayCheckoutHookInterface |
||
152 | */ |
||
153 | public function createCheckoutPostSaveHook(): CrefoPayCheckoutHookInterface |
||
154 | { |
||
155 | return new CrefoPayCheckoutPostSaveHook( |
||
156 | $this->getCrefoPayApiFacade(), |
||
157 | $this->createCheckoutPostSaveHookMapper(), |
||
158 | $this->createCheckoutPostSaveHookSaver(), |
||
159 | ); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * @return \SprykerEco\Zed\CrefoPay\Business\Hook\Checkout\Mapper\CrefoPayCheckoutHookMapperInterface |
||
164 | */ |
||
165 | public function createCheckoutPostSaveHookMapper(): CrefoPayCheckoutHookMapperInterface |
||
166 | { |
||
167 | return new CrefoPayCheckoutPostSaveHookMapper($this->getConfig()); |
||
168 | } |
||
169 | |||
170 | /** |
||
171 | * @return \SprykerEco\Zed\CrefoPay\Business\Hook\Checkout\Saver\CrefoPayCheckoutHookSaverInterface |
||
172 | */ |
||
173 | public function createCheckoutPostSaveHookSaver(): CrefoPayCheckoutHookSaverInterface |
||
174 | { |
||
175 | return new CrefoPayCheckoutPostSaveHookSaver( |
||
176 | $this->createReader(), |
||
177 | $this->createWriter(), |
||
178 | $this->getConfig(), |
||
179 | ); |
||
180 | } |
||
181 | |||
182 | /** |
||
183 | * @return \SprykerEco\Zed\CrefoPay\Business\Mapper\PaymentMethod\CrefoPayPaymentMethodMapperInterface |
||
184 | */ |
||
185 | public function createCrefoPayPaymentMethodMapper(): CrefoPayPaymentMethodMapperInterface |
||
186 | { |
||
187 | return new CrefoPayPaymentMethodMapper($this->getConfig()); |
||
188 | } |
||
189 | |||
190 | /** |
||
191 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CrefoPayOmsCommandInterface |
||
192 | */ |
||
193 | public function createCaptureOmsCommand(): CrefoPayOmsCommandInterface |
||
194 | { |
||
195 | return new CaptureOmsCommand( |
||
196 | $this->createCaptureOmsCommandRequestBuilder(), |
||
197 | $this->createReader(), |
||
198 | $this->createCaptureOmsCommandClient(), |
||
199 | $this->createCaptureOmsCommandSaver(), |
||
200 | ); |
||
201 | } |
||
202 | |||
203 | /** |
||
204 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CrefoPayOmsCommandInterface |
||
205 | */ |
||
206 | public function createCancelOmsCommand(): CrefoPayOmsCommandInterface |
||
207 | { |
||
208 | return new CrefoPayOmsCommandByOrder( |
||
209 | $this->createCancelOmsCommandRequestBuilder(), |
||
210 | $this->createReader(), |
||
211 | $this->createCancelOmsCommandClient(), |
||
212 | $this->createCancelOmsCommandSaver(), |
||
213 | ); |
||
214 | } |
||
215 | |||
216 | /** |
||
217 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\RefundOmsCommandInterface |
||
218 | */ |
||
219 | public function createRefundOmsCommand(): RefundOmsCommandInterface |
||
220 | { |
||
221 | return new RefundOmsCommand( |
||
222 | $this->createRefundOmsCommandRequestBuilder(), |
||
223 | $this->createReader(), |
||
224 | $this->createRefundOmsCommandClient(), |
||
225 | $this->createRefundOmsCommandSaver(), |
||
226 | ); |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CrefoPayOmsCommandInterface |
||
231 | */ |
||
232 | public function createFinishOmsCommand(): CrefoPayOmsCommandInterface |
||
233 | { |
||
234 | return new CrefoPayOmsCommandByOrder( |
||
235 | $this->createFinishOmsCommandRequestBuilder(), |
||
236 | $this->createReader(), |
||
237 | $this->createFinishOmsCommandClient(), |
||
238 | $this->createFinishOmsCommandSaver(), |
||
239 | ); |
||
240 | } |
||
241 | |||
242 | /** |
||
243 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Builder\CrefoPayOmsCommandRequestBuilderInterface |
||
244 | */ |
||
245 | public function createCaptureOmsCommandRequestBuilder(): CrefoPayOmsCommandRequestBuilderInterface |
||
246 | { |
||
247 | return new CaptureOmsCommandRequestBuilder( |
||
248 | $this->getUtilTextService(), |
||
249 | $this->getConfig(), |
||
250 | ); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Builder\CrefoPayOmsCommandRequestBuilderInterface |
||
255 | */ |
||
256 | public function createCancelOmsCommandRequestBuilder(): CrefoPayOmsCommandRequestBuilderInterface |
||
257 | { |
||
258 | return new CancelOmsCommandRequestBuilder($this->getConfig()); |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Builder\CrefoPayOmsCommandRequestBuilderInterface |
||
263 | */ |
||
264 | public function createRefundOmsCommandRequestBuilder(): CrefoPayOmsCommandRequestBuilderInterface |
||
265 | { |
||
266 | return new RefundOmsCommandRequestBuilder($this->getConfig()); |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Builder\CrefoPayOmsCommandRequestBuilderInterface |
||
271 | */ |
||
272 | public function createFinishOmsCommandRequestBuilder(): CrefoPayOmsCommandRequestBuilderInterface |
||
273 | { |
||
274 | return new FinishOmsCommandRequestBuilder($this->getConfig()); |
||
275 | } |
||
276 | |||
277 | /** |
||
278 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CommandClient\CrefoPayOmsCommandClientInterface |
||
279 | */ |
||
280 | public function createCaptureOmsCommandClient(): CrefoPayOmsCommandClientInterface |
||
281 | { |
||
282 | return new CaptureOmsCommandClient($this->getCrefoPayApiFacade()); |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CommandClient\CrefoPayOmsCommandClientInterface |
||
287 | */ |
||
288 | public function createCancelOmsCommandClient(): CrefoPayOmsCommandClientInterface |
||
289 | { |
||
290 | return new CancelOmsCommandClient($this->getCrefoPayApiFacade()); |
||
291 | } |
||
292 | |||
293 | /** |
||
294 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CommandClient\CrefoPayOmsCommandClientInterface |
||
295 | */ |
||
296 | public function createRefundOmsCommandClient(): CrefoPayOmsCommandClientInterface |
||
297 | { |
||
298 | return new RefundOmsCommandClient($this->getCrefoPayApiFacade()); |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\CommandClient\CrefoPayOmsCommandClientInterface |
||
303 | */ |
||
304 | public function createFinishOmsCommandClient(): CrefoPayOmsCommandClientInterface |
||
305 | { |
||
306 | return new FinishOmsCommandClient($this->getCrefoPayApiFacade()); |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Saver\CrefoPayOmsCommandSaverInterface |
||
311 | */ |
||
312 | public function createCaptureOmsCommandSaver(): CrefoPayOmsCommandSaverInterface |
||
313 | { |
||
314 | return new CaptureOmsCommandSaver( |
||
315 | $this->createReader(), |
||
316 | $this->createWriter(), |
||
317 | $this->getConfig(), |
||
318 | $this->getOmsFacade(), |
||
319 | $this->createCrefoPayOmsStatusMapper(), |
||
320 | ); |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Saver\CrefoPayOmsCommandSaverInterface |
||
325 | */ |
||
326 | public function createCancelOmsCommandSaver(): CrefoPayOmsCommandSaverInterface |
||
327 | { |
||
328 | return new CancelOmsCommandSaver( |
||
329 | $this->createReader(), |
||
330 | $this->createWriter(), |
||
331 | $this->getConfig(), |
||
332 | $this->getOmsFacade(), |
||
333 | ); |
||
334 | } |
||
335 | |||
336 | /** |
||
337 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Saver\CrefoPayOmsCommandSaverInterface |
||
338 | */ |
||
339 | public function createRefundOmsCommandSaver(): CrefoPayOmsCommandSaverInterface |
||
340 | { |
||
341 | return new RefundOmsCommandSaver( |
||
342 | $this->createReader(), |
||
343 | $this->createWriter(), |
||
344 | $this->getConfig(), |
||
345 | $this->getRefundFacade(), |
||
346 | ); |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Command\Saver\CrefoPayOmsCommandSaverInterface |
||
351 | */ |
||
352 | public function createFinishOmsCommandSaver(): CrefoPayOmsCommandSaverInterface |
||
353 | { |
||
354 | return new FinishOmsCommandSaver( |
||
355 | $this->createReader(), |
||
356 | $this->createWriter(), |
||
357 | $this->getConfig(), |
||
358 | $this->getOmsFacade(), |
||
359 | ); |
||
360 | } |
||
361 | |||
362 | /** |
||
363 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
364 | */ |
||
365 | public function createIsReserveCallSuccessfulOmsCondition(): CrefoPayOmsConditionInterface |
||
366 | { |
||
367 | return new IsReserveCallSuccessfulOmsCondition($this->createReader()); |
||
368 | } |
||
369 | |||
370 | /** |
||
371 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
372 | */ |
||
373 | public function createIsAcknowledgePendingReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
374 | { |
||
375 | return new IsAcknowledgePendingReceivedOmsCondition( |
||
376 | $this->createReader(), |
||
377 | $this->getConfig(), |
||
378 | ); |
||
379 | } |
||
380 | |||
381 | /** |
||
382 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
383 | */ |
||
384 | public function createIsMerchantPendingReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
385 | { |
||
386 | return new IsMerchantPendingReceivedOmsCondition( |
||
387 | $this->createReader(), |
||
388 | $this->getConfig(), |
||
389 | ); |
||
390 | } |
||
391 | |||
392 | /** |
||
393 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
394 | */ |
||
395 | public function createIsCiaPendingReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
396 | { |
||
397 | return new IsCiaPendingReceivedOmsCondition( |
||
398 | $this->createReader(), |
||
399 | $this->getConfig(), |
||
400 | ); |
||
401 | } |
||
402 | |||
403 | /** |
||
404 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
405 | */ |
||
406 | public function createIsCancelCallSuccessfulOmsCondition(): CrefoPayOmsConditionInterface |
||
407 | { |
||
408 | return new IsCancelCallSuccessfulOmsCondition($this->createReader()); |
||
409 | } |
||
410 | |||
411 | /** |
||
412 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
413 | */ |
||
414 | public function createIsCanceledReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
415 | { |
||
416 | return new IsCanceledReceivedOmsCondition( |
||
417 | $this->createReader(), |
||
418 | $this->getConfig(), |
||
419 | ); |
||
420 | } |
||
421 | |||
422 | /** |
||
423 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
424 | */ |
||
425 | public function createIsExpiredReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
426 | { |
||
427 | return new IsExpiredReceivedOmsCondition( |
||
428 | $this->createReader(), |
||
429 | $this->getConfig(), |
||
430 | ); |
||
431 | } |
||
432 | |||
433 | /** |
||
434 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
435 | */ |
||
436 | public function createIsCaptureCallSuccessfulOmsCondition(): CrefoPayOmsConditionInterface |
||
437 | { |
||
438 | return new IsCaptureCallSuccessfulOmsCondition($this->createReader()); |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
443 | */ |
||
444 | public function createIsPaidReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
445 | { |
||
446 | return new IsPaidReceivedOmsCondition( |
||
447 | $this->createReader(), |
||
448 | $this->getConfig(), |
||
449 | ); |
||
450 | } |
||
451 | |||
452 | /** |
||
453 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
454 | */ |
||
455 | public function createIsFinishCallSuccessfulOmsCondition(): CrefoPayOmsConditionInterface |
||
456 | { |
||
457 | return new IsFinishCallSuccessfulOmsCondition($this->createReader()); |
||
458 | } |
||
459 | |||
460 | /** |
||
461 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
462 | */ |
||
463 | public function createIsRefundCallSuccessfulOmsCondition(): CrefoPayOmsConditionInterface |
||
464 | { |
||
465 | return new IsRefundCallSuccessfulOmsCondition($this->createReader()); |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
470 | */ |
||
471 | public function createIsChargeBackReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
472 | { |
||
473 | return new IsChargeBackReceivedOmsCondition( |
||
474 | $this->createReader(), |
||
475 | $this->getConfig(), |
||
476 | ); |
||
477 | } |
||
478 | |||
479 | /** |
||
480 | * @return \SprykerEco\Zed\CrefoPay\Business\Oms\Condition\CrefoPayOmsConditionInterface |
||
481 | */ |
||
482 | public function createIsDoneReceivedOmsCondition(): CrefoPayOmsConditionInterface |
||
483 | { |
||
484 | return new IsDoneReceivedOmsCondition( |
||
485 | $this->createReader(), |
||
486 | $this->getConfig(), |
||
487 | ); |
||
488 | } |
||
489 | |||
490 | /** |
||
491 | * @return \SprykerEco\Zed\CrefoPay\Business\Writer\CrefoPayWriterInterface |
||
492 | */ |
||
493 | public function createWriter(): CrefoPayWriterInterface |
||
494 | { |
||
495 | return new CrefoPayWriter( |
||
496 | $this->getEntityManager(), |
||
497 | $this->getConfig(), |
||
498 | ); |
||
499 | } |
||
500 | |||
501 | /** |
||
502 | * @return \SprykerEco\Zed\CrefoPay\Business\Reader\CrefoPayReaderInterface |
||
503 | */ |
||
504 | public function createReader(): CrefoPayReaderInterface |
||
505 | { |
||
506 | return new CrefoPayReader($this->getRepository()); |
||
507 | } |
||
508 | |||
509 | /** |
||
510 | * @return \SprykerEco\Zed\CrefoPay\Dependency\Facade\CrefoPayToCrefoPayApiFacadeInterface |
||
511 | */ |
||
512 | public function getCrefoPayApiFacade(): CrefoPayToCrefoPayApiFacadeInterface |
||
515 | } |
||
516 | |||
517 | /** |
||
518 | * @return \SprykerEco\Zed\CrefoPay\Dependency\Facade\CrefoPayToLocaleFacadeInterface |
||
519 | */ |
||
520 | public function getLocaleFacade(): CrefoPayToLocaleFacadeInterface |
||
523 | } |
||
524 | |||
525 | /** |
||
526 | * @return \SprykerEco\Zed\CrefoPay\Dependency\Facade\CrefoPayToOmsFacadeInterface |
||
527 | */ |
||
528 | public function getOmsFacade(): CrefoPayToOmsFacadeInterface |
||
531 | } |
||
532 | |||
533 | /** |
||
534 | * @return \SprykerEco\Service\CrefoPay\CrefoPayServiceInterface |
||
535 | */ |
||
536 | public function getCrefoPayService(): CrefoPayServiceInterface |
||
537 | { |
||
538 | return $this->getProvidedDependency(CrefoPayDependencyProvider::SERVICE_CREFO_PAY); |
||
539 | } |
||
540 | |||
541 | /** |
||
542 | * @return \SprykerEco\Zed\CrefoPay\Dependency\Service\CrefoPayToUtilTextServiceInterface |
||
543 | */ |
||
544 | public function getUtilTextService(): CrefoPayToUtilTextServiceInterface |
||
547 | } |
||
548 | |||
549 | /** |
||
550 | * @return \SprykerEco\Zed\CrefoPay\Dependency\Facade\CrefoPayToRefundFacadeInterface |
||
551 | */ |
||
552 | public function getRefundFacade(): CrefoPayToRefundFacadeInterface |
||
553 | { |
||
554 | return $this->getProvidedDependency(CrefoPayDependencyProvider::FACADE_REFUND); |
||
555 | } |
||
556 | } |
||
557 |