| Total Complexity | 46 |
| Total Lines | 382 |
| Duplicated Lines | 0 % |
| Changes | 7 | ||
| Bugs | 0 | Features | 0 |
Complex classes like PayoneFactory 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 PayoneFactory, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 68 | class PayoneFactory extends AbstractFactory |
||
| 69 | { |
||
| 70 | /** |
||
| 71 | * @var \SprykerEco\Yves\Payone\Model\StoreReaderInterface|null |
||
| 72 | */ |
||
| 73 | protected ?StoreReaderInterface $storeReader = null; |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 77 | */ |
||
| 78 | public function createPrePaymentForm(): AbstractPayoneSubForm |
||
| 79 | { |
||
| 80 | return new PrePaymentForm(); |
||
| 81 | } |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 85 | */ |
||
| 86 | public function createPrePaymentFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 87 | { |
||
| 88 | return new PrePaymentDataProvider(); |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 93 | */ |
||
| 94 | public function createInvoiceSubForm(): AbstractPayoneSubForm |
||
| 95 | { |
||
| 96 | return new InvoiceSubForm(); |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
||
| 101 | */ |
||
| 102 | public function createSecurityInvoiceSubForm(): SubFormInterface |
||
| 103 | { |
||
| 104 | return new SecurityInvoiceSubForm(); |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 109 | */ |
||
| 110 | public function createKlarnaSubForm(): AbstractPayoneSubForm |
||
| 111 | { |
||
| 112 | return new KlarnaSubForm(); |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 117 | */ |
||
| 118 | public function createInvoiceSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 119 | { |
||
| 120 | return new InvoiceDataProvider(); |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
||
| 125 | */ |
||
| 126 | public function createCashOnDeliverySubForm(): SubFormInterface |
||
| 127 | { |
||
| 128 | return new CashOnDeliverySubForm(); |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 133 | */ |
||
| 134 | public function createCashOnDeliverySubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 135 | { |
||
| 136 | return new CashOnDeliveryDataProvider(); |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 141 | */ |
||
| 142 | public function createSecurityInvoiceSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 149 | */ |
||
| 150 | public function createKlarnaDataProvider(): StepEngineFormDataProviderInterface |
||
| 151 | { |
||
| 152 | return new KlarnaDataProvider($this->getClientStore()); |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @return \SprykerEco\Yves\Payone\Handler\PayoneHandlerInterface |
||
| 157 | */ |
||
| 158 | public function createPayoneHandler(): PayoneHandlerInterface |
||
| 159 | { |
||
| 160 | return new PayoneHandler(); |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @return \SprykerEco\Yves\Payone\Handler\ExpressCheckoutHandlerInterface |
||
| 165 | */ |
||
| 166 | public function createExpressCheckoutHandler(): ExpressCheckoutHandlerInterface |
||
| 173 | ); |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @return \Spryker\Yves\StepEngine\Dependency\Plugin\Form\SubFormPluginInterface |
||
| 178 | */ |
||
| 179 | public function createPrePaymentSubFormPlugin(): SubFormPluginInterface |
||
| 180 | { |
||
| 181 | return new PayonePrePaymentSubFormPlugin(); |
||
| 182 | } |
||
| 183 | |||
| 184 | /** |
||
| 185 | * @return \Spryker\Yves\StepEngine\Dependency\Plugin\Form\SubFormPluginInterface |
||
| 186 | */ |
||
| 187 | public function createCreditCardSubFormPlugin(): SubFormPluginInterface |
||
| 190 | } |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 194 | */ |
||
| 195 | public function createCreditCardSubForm(): AbstractPayoneSubForm |
||
| 196 | { |
||
| 197 | return new CreditCardSubForm(); |
||
| 198 | } |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 202 | */ |
||
| 203 | public function createCreditCardSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 204 | { |
||
| 205 | return new CreditCardDataProvider(); |
||
| 206 | } |
||
| 207 | |||
| 208 | /** |
||
| 209 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 210 | */ |
||
| 211 | public function createEWalletSubForm(): AbstractPayoneSubForm |
||
| 214 | } |
||
| 215 | |||
| 216 | /** |
||
| 217 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 218 | */ |
||
| 219 | public function createEWalletSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 220 | { |
||
| 221 | return new EWalletDataProvider(); |
||
| 222 | } |
||
| 223 | |||
| 224 | /** |
||
| 225 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 226 | */ |
||
| 227 | public function createDirectDebitSubForm(): AbstractPayoneSubForm |
||
| 228 | { |
||
| 229 | return new DirectDebitSubForm(); |
||
| 230 | } |
||
| 231 | |||
| 232 | /** |
||
| 233 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 234 | */ |
||
| 235 | public function createDirectDebitSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 236 | { |
||
| 237 | return new DirectDebitDataProvider( |
||
| 238 | $this->getClientStore() |
||
| 239 | ); |
||
| 240 | } |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 244 | */ |
||
| 245 | public function createEpsOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 246 | { |
||
| 247 | return new EpsOnlineTransferSubForm(); |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 252 | */ |
||
| 253 | public function createEpsOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 254 | { |
||
| 255 | return new EpsOnlineTransferDataProvider(); |
||
| 256 | } |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 260 | */ |
||
| 261 | public function createGiropayOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 262 | { |
||
| 263 | return new GiropayOnlineTransferSubForm(); |
||
| 264 | } |
||
| 265 | |||
| 266 | /** |
||
| 267 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 268 | */ |
||
| 269 | public function createGiropayOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 270 | { |
||
| 271 | return new GiropayOnlineTransferDataProvider(); |
||
| 272 | } |
||
| 273 | |||
| 274 | /** |
||
| 275 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 276 | */ |
||
| 277 | public function createInstantOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 278 | { |
||
| 279 | return new InstantOnlineTransferSubForm(); |
||
| 280 | } |
||
| 281 | |||
| 282 | /** |
||
| 283 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 284 | */ |
||
| 285 | public function createInstantOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 286 | { |
||
| 287 | return new InstantOnlineTransferDataProvider( |
||
| 288 | $this->getClientStore(), |
||
| 289 | ); |
||
| 290 | } |
||
| 291 | |||
| 292 | /** |
||
| 293 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 294 | */ |
||
| 295 | public function createIdealOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 298 | } |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 302 | */ |
||
| 303 | public function createIdealOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 304 | { |
||
| 305 | return new IdealOnlineTransferDataProvider(); |
||
| 306 | } |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 310 | */ |
||
| 311 | public function createPostfinanceEfinanceOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 312 | { |
||
| 313 | return new PostfinanceEfinanceOnlineTransferSubForm(); |
||
| 314 | } |
||
| 315 | |||
| 316 | /** |
||
| 317 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 318 | */ |
||
| 319 | public function createPostfinanceEfinanceOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 320 | { |
||
| 321 | return new PostfinanceEfinanceOnlineTransferDataProvider(); |
||
| 322 | } |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 326 | */ |
||
| 327 | public function createPostfinanceCardOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 328 | { |
||
| 329 | return new PostfinanceCardOnlineTransferSubForm(); |
||
| 330 | } |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 334 | */ |
||
| 335 | public function createPostfinanceCardOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 336 | { |
||
| 337 | return new PostfinanceCardOnlineTransferDataProvider(); |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 342 | */ |
||
| 343 | public function createPrzelewy24OnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 344 | { |
||
| 345 | return new Przelewy24OnlineTransferSubForm(); |
||
| 346 | } |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 350 | */ |
||
| 351 | public function createPrzelewy24OnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 352 | { |
||
| 353 | return new Przelewy24OnlineTransferDataProvider(); |
||
| 354 | } |
||
| 355 | |||
| 356 | /** |
||
| 357 | * @return \SprykerEco\Yves\Payone\Form\AbstractPayoneSubForm |
||
| 358 | */ |
||
| 359 | public function createBancontactOnlineTransferSubForm(): AbstractPayoneSubForm |
||
| 360 | { |
||
| 361 | return new BancontactOnlineTransferSubForm(); |
||
| 362 | } |
||
| 363 | |||
| 364 | /** |
||
| 365 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 366 | */ |
||
| 367 | public function createBancontactOnlineTransferSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 370 | } |
||
| 371 | |||
| 372 | /** |
||
| 373 | * @return \SprykerEco\Client\Payone\PayoneClientInterface |
||
| 374 | */ |
||
| 375 | public function getPayoneClient(): PayoneClientInterface |
||
| 376 | { |
||
| 377 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_PAYONE); |
||
| 378 | } |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToCartInterface |
||
| 382 | */ |
||
| 383 | public function getCartClient(): PayoneToCartInterface |
||
| 386 | } |
||
| 387 | |||
| 388 | /** |
||
| 389 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToCustomerInterface |
||
| 390 | */ |
||
| 391 | public function getCustomerClient(): PayoneToCustomerInterface |
||
| 392 | { |
||
| 393 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_CUSTOMER); |
||
| 394 | } |
||
| 395 | |||
| 396 | /** |
||
| 397 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToShipmentInterface |
||
| 398 | */ |
||
| 399 | public function getShipmentClient(): PayoneToShipmentInterface |
||
| 400 | { |
||
| 401 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_SHIPMENT); |
||
| 402 | } |
||
| 403 | |||
| 404 | /** |
||
| 405 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToCalculationInterface |
||
| 406 | */ |
||
| 407 | public function getCalculationClient(): PayoneToCalculationInterface |
||
| 408 | { |
||
| 409 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_CALCULATION); |
||
| 410 | } |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToQuoteClientInterface |
||
| 414 | */ |
||
| 415 | public function getQuoteClient(): PayoneToQuoteClientInterface |
||
| 416 | { |
||
| 417 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_QUOTE); |
||
| 418 | } |
||
| 419 | |||
| 420 | /** |
||
| 421 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToStoreClientInterface |
||
| 422 | */ |
||
| 423 | public function getClientStore(): PayoneToStoreClientInterface |
||
| 424 | { |
||
| 425 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_STORE); |
||
| 426 | } |
||
| 427 | |||
| 428 | /** |
||
| 429 | * @return \SprykerEco\Yves\Payone\Handler\ExpressCheckout\QuoteHydratorInterface |
||
| 430 | */ |
||
| 431 | public function createQuoteHydrator(): QuoteHydratorInterface |
||
| 432 | { |
||
| 433 | return new QuoteHydrator( |
||
| 434 | $this->getShipmentClient(), |
||
| 435 | $this->getCustomerClient(), |
||
| 436 | $this->getCalculationClient() |
||
| 437 | ); |
||
| 438 | } |
||
| 439 | |||
| 440 | /** |
||
| 441 | * @return \SprykerEco\Yves\Payone\Model\StoreReaderInterface |
||
| 442 | */ |
||
| 443 | public function createStoreReader(): StoreReaderInterface |
||
| 450 | } |
||
| 451 | } |
||
| 452 |