Total Complexity | 40 |
Total Lines | 422 |
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 |
||
49 | class CrefoPayApiBusinessFactory extends AbstractBusinessFactory |
||
50 | { |
||
51 | /** |
||
52 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
53 | */ |
||
54 | public function createCreateTransactionClient(): CrefoPayApiClientInterface |
||
55 | { |
||
56 | return new CrefoPayApiClient( |
||
57 | $this->getCrefoPayApiHttpClient(), |
||
58 | $this->createCreateTransactionRequest(), |
||
59 | $this->createCreateTransactionConverter(), |
||
60 | $this->createLogger() |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
66 | */ |
||
67 | public function createReserveClient(): CrefoPayApiClientInterface |
||
68 | { |
||
69 | return new CrefoPayApiClient( |
||
70 | $this->getCrefoPayApiHttpClient(), |
||
71 | $this->createReserveRequest(), |
||
72 | $this->createReserveConverter(), |
||
73 | $this->createLogger() |
||
74 | ); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
79 | */ |
||
80 | public function createCaptureClient(): CrefoPayApiClientInterface |
||
81 | { |
||
82 | return new CrefoPayApiClient( |
||
83 | $this->getCrefoPayApiHttpClient(), |
||
84 | $this->createCaptureRequest(), |
||
85 | $this->createCaptureConverter(), |
||
86 | $this->createLogger() |
||
87 | ); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
92 | */ |
||
93 | public function createCancelClient(): CrefoPayApiClientInterface |
||
94 | { |
||
95 | return new CrefoPayApiClient( |
||
96 | $this->getCrefoPayApiHttpClient(), |
||
97 | $this->createCancelRequest(), |
||
98 | $this->createCancelConverter(), |
||
99 | $this->createLogger() |
||
100 | ); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
105 | */ |
||
106 | public function createRefundClient(): CrefoPayApiClientInterface |
||
107 | { |
||
108 | return new CrefoPayApiClient( |
||
109 | $this->getCrefoPayApiHttpClient(), |
||
110 | $this->createRefundRequest(), |
||
111 | $this->createRefundConverter(), |
||
112 | $this->createLogger() |
||
113 | ); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Client\CrefoPayApiClientInterface |
||
118 | */ |
||
119 | public function createFinishClient(): CrefoPayApiClientInterface |
||
120 | { |
||
121 | return new CrefoPayApiClient( |
||
122 | $this->getCrefoPayApiHttpClient(), |
||
123 | $this->createFinishRequest(), |
||
124 | $this->createFinishConverter(), |
||
125 | $this->createLogger() |
||
126 | ); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
131 | */ |
||
132 | public function createCreateTransactionRequest(): CrefoPayApiRequestInterface |
||
133 | { |
||
134 | return new CreateTransactionRequest( |
||
135 | $this->createCreateTransactionRequestBuilder(), |
||
136 | $this->getConfig() |
||
137 | ); |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
142 | */ |
||
143 | public function createReserveRequest(): CrefoPayApiRequestInterface |
||
144 | { |
||
145 | return new ReserveRequest( |
||
146 | $this->createReserveRequestBuilder(), |
||
147 | $this->getConfig() |
||
148 | ); |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
153 | */ |
||
154 | public function createCaptureRequest(): CrefoPayApiRequestInterface |
||
155 | { |
||
156 | return new CaptureRequest( |
||
157 | $this->createCaptureRequestBuilder(), |
||
158 | $this->getConfig() |
||
159 | ); |
||
160 | } |
||
161 | |||
162 | /** |
||
163 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
164 | */ |
||
165 | public function createCancelRequest(): CrefoPayApiRequestInterface |
||
166 | { |
||
167 | return new CancelRequest( |
||
168 | $this->createCancelRequestBuilder(), |
||
169 | $this->getConfig() |
||
170 | ); |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
175 | */ |
||
176 | public function createRefundRequest(): CrefoPayApiRequestInterface |
||
177 | { |
||
178 | return new RefundRequest( |
||
179 | $this->createRefundRequestBuilder(), |
||
180 | $this->getConfig() |
||
181 | ); |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\CrefoPayApiRequestInterface |
||
186 | */ |
||
187 | public function createFinishRequest(): CrefoPayApiRequestInterface |
||
188 | { |
||
189 | return new FinishRequest( |
||
190 | $this->createFinishRequestBuilder(), |
||
191 | $this->getConfig() |
||
192 | ); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
197 | */ |
||
198 | public function createCreateTransactionRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
199 | { |
||
200 | return new CrefoPayApiRequestBuilder( |
||
201 | $this->createCreateTransactionRequestConverter(), |
||
202 | $this->getUtilEncodingService(), |
||
203 | $this->getCrefoPayApiService(), |
||
204 | $this->getConfig() |
||
205 | ); |
||
206 | } |
||
207 | |||
208 | /** |
||
209 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
210 | */ |
||
211 | public function createReserveRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
212 | { |
||
213 | return new CrefoPayApiRequestBuilder( |
||
214 | $this->createReserveRequestConverter(), |
||
215 | $this->getUtilEncodingService(), |
||
216 | $this->getCrefoPayApiService(), |
||
217 | $this->getConfig() |
||
218 | ); |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
223 | */ |
||
224 | public function createCaptureRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
225 | { |
||
226 | return new CrefoPayApiRequestBuilder( |
||
227 | $this->createCaptureRequestConverter(), |
||
228 | $this->getUtilEncodingService(), |
||
229 | $this->getCrefoPayApiService(), |
||
230 | $this->getConfig() |
||
231 | ); |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
236 | */ |
||
237 | public function createCancelRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
238 | { |
||
239 | return new CrefoPayApiRequestBuilder( |
||
240 | $this->createCancelRequestConverter(), |
||
241 | $this->getUtilEncodingService(), |
||
242 | $this->getCrefoPayApiService(), |
||
243 | $this->getConfig() |
||
244 | ); |
||
245 | } |
||
246 | |||
247 | /** |
||
248 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
249 | */ |
||
250 | public function createRefundRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
251 | { |
||
252 | return new CrefoPayApiRequestBuilder( |
||
253 | $this->createRefundRequestConverter(), |
||
254 | $this->getUtilEncodingService(), |
||
255 | $this->getCrefoPayApiService(), |
||
256 | $this->getConfig() |
||
257 | ); |
||
258 | } |
||
259 | |||
260 | /** |
||
261 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Builder\CrefoPayApiRequestBuilderInterface |
||
262 | */ |
||
263 | public function createFinishRequestBuilder(): CrefoPayApiRequestBuilderInterface |
||
264 | { |
||
265 | return new CrefoPayApiRequestBuilder( |
||
266 | $this->createFinishRequestConverter(), |
||
267 | $this->getUtilEncodingService(), |
||
268 | $this->getCrefoPayApiService(), |
||
269 | $this->getConfig() |
||
270 | ); |
||
271 | } |
||
272 | |||
273 | /** |
||
274 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
275 | */ |
||
276 | public function createCreateTransactionRequestConverter(): CrefoPayApiRequestConverterInterface |
||
277 | { |
||
278 | return new CreateTransactionRequestConverter(); |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
283 | */ |
||
284 | public function createReserveRequestConverter(): CrefoPayApiRequestConverterInterface |
||
285 | { |
||
286 | return new ReserveRequestConverter(); |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
291 | */ |
||
292 | public function createCaptureRequestConverter(): CrefoPayApiRequestConverterInterface |
||
293 | { |
||
294 | return new CaptureRequestConverter(); |
||
295 | } |
||
296 | |||
297 | /** |
||
298 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
299 | */ |
||
300 | public function createCancelRequestConverter(): CrefoPayApiRequestConverterInterface |
||
301 | { |
||
302 | return new CancelRequestConverter(); |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
307 | */ |
||
308 | public function createRefundRequestConverter(): CrefoPayApiRequestConverterInterface |
||
309 | { |
||
310 | return new RefundRequestConverter(); |
||
311 | } |
||
312 | |||
313 | /** |
||
314 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Request\Converter\CrefoPayApiRequestConverterInterface |
||
315 | */ |
||
316 | public function createFinishRequestConverter(): CrefoPayApiRequestConverterInterface |
||
317 | { |
||
318 | return new FinishRequestConverter(); |
||
319 | } |
||
320 | |||
321 | /** |
||
322 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
323 | */ |
||
324 | public function createCreateTransactionConverter(): CrefoPayApiResponseConverterInterface |
||
325 | { |
||
326 | return new CrefoPayApiResponseConverter( |
||
327 | $this->getUtilEncodingService(), |
||
328 | $this->createCreateTransactionResponseMapper(), |
||
329 | $this->getConfig() |
||
330 | ); |
||
331 | } |
||
332 | |||
333 | /** |
||
334 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
335 | */ |
||
336 | public function createReserveConverter(): CrefoPayApiResponseConverterInterface |
||
342 | ); |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
347 | */ |
||
348 | public function createCaptureConverter(): CrefoPayApiResponseConverterInterface |
||
349 | { |
||
350 | return new CrefoPayApiResponseConverter( |
||
351 | $this->getUtilEncodingService(), |
||
352 | $this->createCaptureResponseMapper(), |
||
353 | $this->getConfig() |
||
354 | ); |
||
355 | } |
||
356 | |||
357 | /** |
||
358 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
359 | */ |
||
360 | public function createCancelConverter(): CrefoPayApiResponseConverterInterface |
||
361 | { |
||
362 | return new CrefoPayApiResponseConverter( |
||
363 | $this->getUtilEncodingService(), |
||
364 | $this->createCancelResponseMapper(), |
||
365 | $this->getConfig() |
||
366 | ); |
||
367 | } |
||
368 | |||
369 | /** |
||
370 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
371 | */ |
||
372 | public function createRefundConverter(): CrefoPayApiResponseConverterInterface |
||
378 | ); |
||
379 | } |
||
380 | |||
381 | /** |
||
382 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Converter\CrefoPayApiResponseConverterInterface |
||
383 | */ |
||
384 | public function createFinishConverter(): CrefoPayApiResponseConverterInterface |
||
385 | { |
||
386 | return new CrefoPayApiResponseConverter( |
||
387 | $this->getUtilEncodingService(), |
||
388 | $this->createFinishResponseMapper(), |
||
389 | $this->getConfig() |
||
390 | ); |
||
391 | } |
||
392 | |||
393 | /** |
||
394 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
395 | */ |
||
396 | public function createCreateTransactionResponseMapper(): CrefoPayApiResponseMapperInterface |
||
397 | { |
||
398 | return new CreateTransactionResponseMapper(); |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
403 | */ |
||
404 | public function createReserveResponseMapper(): CrefoPayApiResponseMapperInterface |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
411 | */ |
||
412 | public function createCaptureResponseMapper(): CrefoPayApiResponseMapperInterface |
||
413 | { |
||
414 | return new CaptureResponseMapper(); |
||
415 | } |
||
416 | |||
417 | /** |
||
418 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
419 | */ |
||
420 | public function createCancelResponseMapper(): CrefoPayApiResponseMapperInterface |
||
421 | { |
||
422 | return new CancelResponseMapper(); |
||
423 | } |
||
424 | |||
425 | /** |
||
426 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
427 | */ |
||
428 | public function createRefundResponseMapper(): CrefoPayApiResponseMapperInterface |
||
429 | { |
||
430 | return new RefundResponseMapper(); |
||
431 | } |
||
432 | |||
433 | /** |
||
434 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Response\Mapper\CrefoPayApiResponseMapperInterface |
||
435 | */ |
||
436 | public function createFinishResponseMapper(): CrefoPayApiResponseMapperInterface |
||
437 | { |
||
438 | return new FinishResponseMapper(); |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * @return \SprykerEco\Zed\CrefoPayApi\Business\Logger\CrefoPayApiLoggerInterface |
||
443 | */ |
||
444 | public function createLogger(): CrefoPayApiLoggerInterface |
||
445 | { |
||
446 | return new CrefoPayApiLogger($this->getEntityManager()); |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * @return \SprykerEco\Zed\CrefoPayApi\Dependency\Service\CrefoPayApiToUtilEncodingServiceInterface |
||
451 | */ |
||
452 | public function getUtilEncodingService(): CrefoPayApiToUtilEncodingServiceInterface |
||
453 | { |
||
454 | return $this->getProvidedDependency(CrefoPayApiDependencyProvider::SERVICE_UTIL_ENCODING); |
||
455 | } |
||
456 | |||
457 | /** |
||
458 | * @return \SprykerEco\Service\CrefoPayApi\CrefoPayApiServiceInterface |
||
459 | */ |
||
460 | public function getCrefoPayApiService(): CrefoPayApiServiceInterface |
||
461 | { |
||
462 | return $this->getProvidedDependency(CrefoPayApiDependencyProvider::SERVICE_CREFO_PAY_API); |
||
463 | } |
||
464 | |||
465 | /** |
||
466 | * @return \SprykerEco\Zed\CrefoPayApi\Dependency\External\Guzzle\CrefoPayApiGuzzleHttpClientAdapterInterface |
||
467 | */ |
||
468 | public function getCrefoPayApiHttpClient(): CrefoPayApiGuzzleHttpClientAdapterInterface |
||
471 | } |
||
472 | } |
||
473 |
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