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