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