Total Complexity | 41 |
Total Lines | 439 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like CrefoPayApiBusinessFactory 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 CrefoPayApiBusinessFactory, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
51 | class CrefoPayApiBusinessFactory extends AbstractBusinessFactory |
||
52 | { |
||
53 | /** |
||
54 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
55 | */ |
||
56 | public function createCreateTransactionClient(): CrefoPayApiClientInterface |
||
57 | { |
||
58 | return new CrefoPayApiClient( |
||
59 | $this->getCrefoPayApiHttpClient(), |
||
60 | $this->createCreateTransactionRequest(), |
||
61 | $this->createCreateTransactionResponseConverter(), |
||
62 | $this->createCrefoPayApiLogger() |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
68 | */ |
||
69 | public function createReserveClient(): CrefoPayApiClientInterface |
||
70 | { |
||
71 | return new CrefoPayApiClient( |
||
72 | $this->getCrefoPayApiHttpClient(), |
||
73 | $this->createReserveRequest(), |
||
74 | $this->createReserveResponseConverter(), |
||
75 | $this->createCrefoPayApiLogger() |
||
76 | ); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
81 | */ |
||
82 | public function createCaptureClient(): CrefoPayApiClientInterface |
||
83 | { |
||
84 | return new CrefoPayApiClient( |
||
85 | $this->getCrefoPayApiHttpClient(), |
||
86 | $this->createCaptureRequest(), |
||
87 | $this->createCaptureResponseConverter(), |
||
88 | $this->createCrefoPayApiLogger() |
||
89 | ); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
94 | */ |
||
95 | public function createCancelClient(): CrefoPayApiClientInterface |
||
96 | { |
||
97 | return new CrefoPayApiClient( |
||
98 | $this->getCrefoPayApiHttpClient(), |
||
99 | $this->createCancelRequest(), |
||
100 | $this->createCancelResponseConverter(), |
||
101 | $this->createCrefoPayApiLogger() |
||
102 | ); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
107 | */ |
||
108 | public function createRefundClient(): CrefoPayApiClientInterface |
||
109 | { |
||
110 | return new CrefoPayApiClient( |
||
111 | $this->getCrefoPayApiHttpClient(), |
||
112 | $this->createRefundRequest(), |
||
113 | $this->createRefundResponseConverter(), |
||
114 | $this->createCrefoPayApiLogger() |
||
115 | ); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
120 | */ |
||
121 | public function createFinishClient(): CrefoPayApiClientInterface |
||
122 | { |
||
123 | return new CrefoPayApiClient( |
||
124 | $this->getCrefoPayApiHttpClient(), |
||
125 | $this->createFinishRequest(), |
||
126 | $this->createFinishResponseConverter(), |
||
127 | $this->createCrefoPayApiLogger() |
||
128 | ); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
133 | */ |
||
134 | public function createCreateTransactionRequest(): CrefoPayApiRequestInterface |
||
135 | { |
||
136 | return new CreateTransactionRequest( |
||
137 | $this->createCreateTransactionRequestBuilder(), |
||
138 | $this->getConfig() |
||
139 | ); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
144 | */ |
||
145 | public function createReserveRequest(): CrefoPayApiRequestInterface |
||
146 | { |
||
147 | return new ReserveRequest( |
||
148 | $this->createReserveRequestBuilder(), |
||
149 | $this->getConfig() |
||
150 | ); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
155 | */ |
||
156 | public function createCaptureRequest(): CrefoPayApiRequestInterface |
||
157 | { |
||
158 | return new CaptureRequest( |
||
159 | $this->createCaptureRequestBuilder(), |
||
160 | $this->getConfig() |
||
161 | ); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
166 | */ |
||
167 | public function createCancelRequest(): CrefoPayApiRequestInterface |
||
168 | { |
||
169 | return new CancelRequest( |
||
170 | $this->createCancelRequestBuilder(), |
||
171 | $this->getConfig() |
||
172 | ); |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
177 | */ |
||
178 | public function createRefundRequest(): CrefoPayApiRequestInterface |
||
179 | { |
||
180 | return new RefundRequest( |
||
181 | $this->createRefundRequestBuilder(), |
||
182 | $this->getConfig() |
||
183 | ); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
188 | */ |
||
189 | public function createFinishRequest(): CrefoPayApiRequestInterface |
||
190 | { |
||
191 | return new FinishRequest( |
||
192 | $this->createFinishRequestBuilder(), |
||
193 | $this->getConfig() |
||
194 | ); |
||
195 | } |
||
196 | |||
197 | /** |
||
198 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
199 | */ |
||
200 | public function createCreateTransactionRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
201 | { |
||
202 | return new CrefoPayApiRequestBuilder( |
||
203 | $this->createCreateTransactionRequestConverter(), |
||
204 | $this->getUtilEncodingService(), |
||
205 | $this->getCrefoPayApiService(), |
||
206 | $this->getConfig() |
||
207 | ); |
||
208 | } |
||
209 | |||
210 | /** |
||
211 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
212 | */ |
||
213 | public function createReserveRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
220 | ); |
||
221 | } |
||
222 | |||
223 | /** |
||
224 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
225 | */ |
||
226 | public function createCaptureRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
227 | { |
||
228 | return new CrefoPayApiRequestBuilder( |
||
229 | $this->createCaptureRequestConverter(), |
||
230 | $this->getUtilEncodingService(), |
||
231 | $this->getCrefoPayApiService(), |
||
232 | $this->getConfig() |
||
233 | ); |
||
234 | } |
||
235 | |||
236 | /** |
||
237 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
238 | */ |
||
239 | public function createCancelRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
240 | { |
||
241 | return new CrefoPayApiRequestBuilder( |
||
242 | $this->createCancelRequestConverter(), |
||
243 | $this->getUtilEncodingService(), |
||
244 | $this->getCrefoPayApiService(), |
||
245 | $this->getConfig() |
||
246 | ); |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
251 | */ |
||
252 | public function createRefundRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
253 | { |
||
254 | return new CrefoPayApiRequestBuilder( |
||
255 | $this->createRefundRequestConverter(), |
||
256 | $this->getUtilEncodingService(), |
||
257 | $this->getCrefoPayApiService(), |
||
258 | $this->getConfig() |
||
259 | ); |
||
260 | } |
||
261 | |||
262 | /** |
||
263 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
264 | */ |
||
265 | public function createFinishRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
272 | ); |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
277 | */ |
||
278 | public function createCreateTransactionRequestConverter(): CrefoPayApiRequestConverterInterface |
||
279 | { |
||
280 | return new CreateTransactionRequestConverter(); |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
285 | */ |
||
286 | public function createReserveRequestConverter(): CrefoPayApiRequestConverterInterface |
||
287 | { |
||
288 | return new ReserveRequestConverter(); |
||
289 | } |
||
290 | |||
291 | /** |
||
292 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
293 | */ |
||
294 | public function createCaptureRequestConverter(): CrefoPayApiRequestConverterInterface |
||
295 | { |
||
296 | return new CaptureRequestConverter(); |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
301 | */ |
||
302 | public function createCancelRequestConverter(): CrefoPayApiRequestConverterInterface |
||
303 | { |
||
304 | return new CancelRequestConverter(); |
||
305 | } |
||
306 | |||
307 | /** |
||
308 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
309 | */ |
||
310 | public function createRefundRequestConverter(): CrefoPayApiRequestConverterInterface |
||
311 | { |
||
312 | return new RefundRequestConverter(); |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
317 | */ |
||
318 | public function createFinishRequestConverter(): CrefoPayApiRequestConverterInterface |
||
319 | { |
||
320 | return new FinishRequestConverter(); |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
325 | */ |
||
326 | public function createCreateTransactionResponseConverter(): CrefoPayApiResponseConverterInterface |
||
327 | { |
||
328 | return new CrefoPayApiResponseConverter( |
||
329 | $this->getUtilEncodingService(), |
||
330 | $this->createCreateTransactionResponseMapper(), |
||
331 | $this->createCrefoPayApiResponseValidator(), |
||
332 | $this->getConfig() |
||
333 | ); |
||
334 | } |
||
335 | |||
336 | /** |
||
337 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
338 | */ |
||
339 | public function createReserveResponseConverter(): CrefoPayApiResponseConverterInterface |
||
340 | { |
||
341 | return new CrefoPayApiResponseConverter( |
||
342 | $this->getUtilEncodingService(), |
||
343 | $this->createReserveResponseMapper(), |
||
344 | $this->createCrefoPayApiResponseValidator(), |
||
345 | $this->getConfig() |
||
346 | ); |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
351 | */ |
||
352 | public function createCaptureResponseConverter(): CrefoPayApiResponseConverterInterface |
||
353 | { |
||
354 | return new CrefoPayApiResponseConverter( |
||
355 | $this->getUtilEncodingService(), |
||
356 | $this->createCaptureResponseMapper(), |
||
357 | $this->createCrefoPayApiResponseValidator(), |
||
358 | $this->getConfig() |
||
359 | ); |
||
360 | } |
||
361 | |||
362 | /** |
||
363 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
364 | */ |
||
365 | public function createCancelResponseConverter(): CrefoPayApiResponseConverterInterface |
||
372 | ); |
||
373 | } |
||
374 | |||
375 | /** |
||
376 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
377 | */ |
||
378 | public function createRefundResponseConverter(): CrefoPayApiResponseConverterInterface |
||
379 | { |
||
380 | return new CrefoPayApiResponseConverter( |
||
381 | $this->getUtilEncodingService(), |
||
382 | $this->createRefundResponseMapper(), |
||
383 | $this->createCrefoPayApiResponseValidator(), |
||
384 | $this->getConfig() |
||
385 | ); |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
390 | */ |
||
391 | public function createFinishResponseConverter(): CrefoPayApiResponseConverterInterface |
||
398 | ); |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
403 | */ |
||
404 | public function createCreateTransactionResponseMapper(): CrefoPayApiResponseMapperInterface |
||
405 | { |
||
406 | return new CreateTransactionResponseMapper(); |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
411 | */ |
||
412 | public function createReserveResponseMapper(): CrefoPayApiResponseMapperInterface |
||
413 | { |
||
414 | return new ReserveResponseMapper(); |
||
415 | } |
||
416 | |||
417 | /** |
||
418 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
419 | */ |
||
420 | public function createCaptureResponseMapper(): CrefoPayApiResponseMapperInterface |
||
421 | { |
||
422 | return new CaptureResponseMapper(); |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
427 | */ |
||
428 | public function createCancelResponseMapper(): CrefoPayApiResponseMapperInterface |
||
429 | { |
||
430 | return new CancelResponseMapper(); |
||
431 | } |
||
432 | |||
433 | /** |
||
434 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
435 | */ |
||
436 | public function createRefundResponseMapper(): CrefoPayApiResponseMapperInterface |
||
437 | { |
||
438 | return new RefundResponseMapper(); |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
443 | */ |
||
444 | public function createFinishResponseMapper(): CrefoPayApiResponseMapperInterface |
||
445 | { |
||
446 | return new FinishResponseMapper(); |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Validator\CrefoPayApiResponseValidatorInterface |
||
451 | */ |
||
452 | public function createCrefoPayApiResponseValidator(): CrefoPayApiResponseValidatorInterface |
||
457 | ); |
||
458 | } |
||
459 | |||
460 | /** |
||
461 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Logger\CrefoPayApiLoggerInterface |
||
462 | */ |
||
463 | public function createCrefoPayApiLogger(): CrefoPayApiLoggerInterface |
||
464 | { |
||
465 | return new CrefoPayApiLogger($this->getEntityManager()); |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * @return \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface |
||
470 | */ |
||
471 | public function getUtilEncodingService(): CrefoPayApiToUtilEncodingServiceInterface |
||
472 | { |
||
473 | return $this->getProvidedDependency(CrefoPayApiDependencyProvider::SERVICE_UTIL_ENCODING); |
||
474 | } |
||
475 | |||
476 | /** |
||
477 | * @return \SprykerEco\Service\CrefoPayApi\CrefoPayApiServiceInterface |
||
478 | */ |
||
479 | public function getCrefoPayApiService(): CrefoPayApiServiceInterface |
||
480 | { |
||
481 | return $this->getProvidedDependency(CrefoPayApiDependencyProvider::SERVICE_CREFO_PAY_API); |
||
482 | } |
||
483 | |||
484 | /** |
||
485 | * @return \SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\CrefoPayApiGuzzleHttpClientAdapterInterface |
||
486 | */ |
||
487 | public function getCrefoPayApiHttpClient(): CrefoPayApiGuzzleHttpClientAdapterInterface |
||
490 | } |
||
491 | } |
||
492 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths