| Total Complexity | 40 |
| Total Lines | 328 |
| Duplicated Lines | 0 % |
| Changes | 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 |
||
| 52 | class PayoneFactory extends AbstractFactory |
||
| 53 | { |
||
| 54 | /** |
||
| 55 | * @return \SprykerEco\Yves\Payone\Form\PrePaymentForm |
||
| 56 | */ |
||
| 57 | public function createPrePaymentForm() |
||
| 58 | { |
||
| 59 | return new PrePaymentForm(); |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\PrePaymentDataProvider |
||
| 64 | */ |
||
| 65 | public function createPrePaymentFormDataProvider() |
||
| 66 | { |
||
| 67 | return new PrePaymentDataProvider(); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @return \SprykerEco\Yves\Payone\Form\InvoiceSubForm |
||
| 72 | */ |
||
| 73 | public function createInvoiceSubForm() |
||
| 74 | { |
||
| 75 | return new InvoiceSubForm(); |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
||
| 80 | */ |
||
| 81 | public function createSecurityInvoiceSubForm(): SubFormInterface |
||
| 82 | { |
||
| 83 | return new SecurityInvoiceSubForm(); |
||
| 84 | } |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\InvoiceDataProvider |
||
| 88 | */ |
||
| 89 | public function createInvoiceSubFormDataProvider() |
||
| 90 | { |
||
| 91 | return new InvoiceDataProvider(); |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @return \Spryker\Yves\StepEngine\Dependency\Form\SubFormInterface |
||
| 96 | */ |
||
| 97 | public function createCashOnDeliverySubForm(): SubFormInterface |
||
| 98 | { |
||
| 99 | return new CashOnDeliverySubForm(); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 104 | */ |
||
| 105 | public function createCashOnDeliverySubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 106 | { |
||
| 107 | return new CashOnDeliveryDataProvider(); |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @return \Spryker\Yves\StepEngine\Dependency\Form\StepEngineFormDataProviderInterface |
||
| 112 | */ |
||
| 113 | public function createSecurityInvoiceSubFormDataProvider(): StepEngineFormDataProviderInterface |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @return \SprykerEco\Yves\Payone\Handler\PayoneHandler |
||
| 120 | */ |
||
| 121 | public function createPayoneHandler() |
||
| 122 | { |
||
| 123 | return new PayoneHandler(); |
||
| 124 | } |
||
| 125 | |||
| 126 | /** |
||
| 127 | * @return \SprykerEco\Yves\Payone\Handler\ExpressCheckoutHandler |
||
| 128 | */ |
||
| 129 | public function createExpressCheckoutHandler() |
||
| 136 | ); |
||
| 137 | } |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @return \SprykerEco\Yves\Payone\Plugin\PayonePrePaymentSubFormPlugin |
||
| 141 | */ |
||
| 142 | public function createPrePaymentSubFormPlugin() |
||
| 143 | { |
||
| 144 | return new PayonePrePaymentSubFormPlugin(); |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @return \SprykerEco\Yves\Payone\Plugin\PayoneCreditCardSubFormPlugin |
||
| 149 | */ |
||
| 150 | public function createCreditCardSubFormPlugin() |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @return \SprykerEco\Yves\Payone\Form\CreditCardSubForm |
||
| 157 | */ |
||
| 158 | public function createCreditCardSubForm() |
||
| 159 | { |
||
| 160 | return new CreditCardSubForm(); |
||
| 161 | } |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\CreditCardDataProvider |
||
| 165 | */ |
||
| 166 | public function createCreditCardSubFormDataProvider() |
||
| 167 | { |
||
| 168 | return new CreditCardDataProvider(); |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * @return \SprykerEco\Yves\Payone\Form\EWalletSubForm |
||
| 173 | */ |
||
| 174 | public function createEWalletSubForm() |
||
| 175 | { |
||
| 176 | return new EWalletSubForm(); |
||
| 177 | } |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\EWalletDataProvider |
||
| 181 | */ |
||
| 182 | public function createEWalletSubFormDataProvider() |
||
| 183 | { |
||
| 184 | return new EWalletDataProvider(); |
||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * @return \SprykerEco\Yves\Payone\Form\DirectDebitSubForm |
||
| 189 | */ |
||
| 190 | public function createDirectDebitSubForm() |
||
| 191 | { |
||
| 192 | return new DirectDebitSubForm(); |
||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\DirectDebitDataProvider |
||
| 197 | */ |
||
| 198 | public function createDirectDebitSubFormDataProvider() |
||
| 199 | { |
||
| 200 | return new DirectDebitDataProvider(); |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * @return \SprykerEco\Yves\Payone\Form\EpsOnlineTransferSubForm |
||
| 205 | */ |
||
| 206 | public function createEpsOnlineTransferSubForm() |
||
| 207 | { |
||
| 208 | return new EpsOnlineTransferSubForm(); |
||
| 209 | } |
||
| 210 | |||
| 211 | /** |
||
| 212 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\EpsOnlineTransferDataProvider |
||
| 213 | */ |
||
| 214 | public function createEpsOnlineTransferSubFormDataProvider() |
||
| 215 | { |
||
| 216 | return new EpsOnlineTransferDataProvider(); |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @return \SprykerEco\Yves\Payone\Form\GiropayOnlineTransferSubForm |
||
| 221 | */ |
||
| 222 | public function createGiropayOnlineTransferSubForm() |
||
| 223 | { |
||
| 224 | return new GiropayOnlineTransferSubForm(); |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\GiropayOnlineTransferDataProvider |
||
| 229 | */ |
||
| 230 | public function createGiropayOnlineTransferSubFormDataProvider() |
||
| 231 | { |
||
| 232 | return new GiropayOnlineTransferDataProvider(); |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @return \SprykerEco\Yves\Payone\Form\InstantOnlineTransferSubForm |
||
| 237 | */ |
||
| 238 | public function createInstantOnlineTransferSubForm() |
||
| 239 | { |
||
| 240 | return new InstantOnlineTransferSubForm(); |
||
| 241 | } |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\InstantOnlineTransferDataProvider |
||
| 245 | */ |
||
| 246 | public function createInstantOnlineTransferSubFormDataProvider() |
||
| 247 | { |
||
| 248 | return new InstantOnlineTransferDataProvider(); |
||
| 249 | } |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @return \SprykerEco\Yves\Payone\Form\IdealOnlineTransferSubForm |
||
| 253 | */ |
||
| 254 | public function createIdealOnlineTransferSubForm() |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\IdealOnlineTransferDataProvider |
||
| 261 | */ |
||
| 262 | public function createIdealOnlineTransferSubFormDataProvider() |
||
| 263 | { |
||
| 264 | return new IdealOnlineTransferDataProvider(); |
||
| 265 | } |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @return \SprykerEco\Yves\Payone\Form\PostfinanceEfinanceOnlineTransferSubForm |
||
| 269 | */ |
||
| 270 | public function createPostfinanceEfinanceOnlineTransferSubForm() |
||
| 271 | { |
||
| 272 | return new PostfinanceEfinanceOnlineTransferSubForm(); |
||
| 273 | } |
||
| 274 | |||
| 275 | /** |
||
| 276 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\PostfinanceEfinanceOnlineTransferDataProvider |
||
| 277 | */ |
||
| 278 | public function createPostfinanceEfinanceOnlineTransferSubFormDataProvider() |
||
| 279 | { |
||
| 280 | return new PostfinanceEfinanceOnlineTransferDataProvider(); |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @return \SprykerEco\Yves\Payone\Form\PostfinanceCardOnlineTransferSubForm |
||
| 285 | */ |
||
| 286 | public function createPostfinanceCardOnlineTransferSubForm() |
||
| 287 | { |
||
| 288 | return new PostfinanceCardOnlineTransferSubForm(); |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\PostfinanceCardOnlineTransferDataProvider |
||
| 293 | */ |
||
| 294 | public function createPostfinanceCardOnlineTransferSubFormDataProvider() |
||
| 295 | { |
||
| 296 | return new PostfinanceCardOnlineTransferDataProvider(); |
||
| 297 | } |
||
| 298 | |||
| 299 | /** |
||
| 300 | * @return \SprykerEco\Yves\Payone\Form\PostfinanceCardOnlineTransferSubForm |
||
| 301 | */ |
||
| 302 | public function createPrzelewy24OnlineTransferSubForm() |
||
| 303 | { |
||
| 304 | return new Przelewy24OnlineTransferSubForm(); |
||
|
|
|||
| 305 | } |
||
| 306 | |||
| 307 | /** |
||
| 308 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\PostfinanceCardOnlineTransferDataProvider |
||
| 309 | */ |
||
| 310 | public function createPrzelewy24OnlineTransferSubFormDataProvider() |
||
| 311 | { |
||
| 312 | return new Przelewy24OnlineTransferDataProvider(); |
||
| 313 | } |
||
| 314 | |||
| 315 | /** |
||
| 316 | * @return \SprykerEco\Yves\Payone\Form\BancontactOnlineTransferSubForm |
||
| 317 | */ |
||
| 318 | public function createBancontactOnlineTransferSubForm(): BancontactOnlineTransferSubForm |
||
| 319 | { |
||
| 320 | return new BancontactOnlineTransferSubForm(); |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @return \SprykerEco\Yves\Payone\Form\DataProvider\BancontactOnlineTransferDataProvider |
||
| 325 | */ |
||
| 326 | public function createBancontactOnlineTransferSubFormDataProvider(): BancontactOnlineTransferDataProvider |
||
| 329 | } |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @return \SprykerEco\Client\Payone\PayoneClientInterface |
||
| 333 | */ |
||
| 334 | public function getPayoneClient() |
||
| 335 | { |
||
| 336 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_PAYONE); |
||
| 337 | } |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToCartInterface |
||
| 341 | */ |
||
| 342 | public function getCartClient() |
||
| 345 | } |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToCustomerInterface |
||
| 349 | */ |
||
| 350 | public function getCustomerClient() |
||
| 351 | { |
||
| 352 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_CUSTOMER); |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToShipmentInterface |
||
| 357 | */ |
||
| 358 | public function getShipmentClient() |
||
| 359 | { |
||
| 360 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_SHIPMENT); |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @return \SprykerEco\Yves\Payone\Dependency\Client\PayoneToCalculationInterface |
||
| 365 | */ |
||
| 366 | public function getCalculationClient() |
||
| 367 | { |
||
| 368 | return $this->getProvidedDependency(PayoneDependencyProvider::CLIENT_CALCULATION); |
||
| 369 | } |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @return \SprykerEco\Yves\Payone\Handler\ExpressCheckout\QuoteHydrator |
||
| 373 | */ |
||
| 374 | public function createQuoteHydrator() |
||
| 380 | ); |
||
| 381 | } |
||
| 382 | } |
||
| 383 |