Complex classes like AbstractThemeConfiguration 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
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 AbstractThemeConfiguration, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
9 | abstract class AbstractThemeConfiguration extends AbstractConfigurableElement implements ThemeConfigurationInterface // ThemeConfigurationInterface is here simply for compatibility for extractors |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @var string The continue button when choosing the checkout type |
||
14 | */ |
||
15 | |||
16 | public $continueButtonXpath; |
||
17 | |||
18 | /** |
||
19 | * @var string The checkbox (typically) that sets the guest checkout |
||
20 | */ |
||
21 | |||
22 | public $guestCheckoutButtonXpath; |
||
23 | |||
24 | /** |
||
25 | * @var string The checkbox (typically) that sets the new customer checkout |
||
26 | */ |
||
27 | |||
28 | public $registerNewCustomerCheckoutButtonXpath; |
||
29 | |||
30 | public $billingAddressDropdownXpath; |
||
31 | |||
32 | public $customerEmailInputXpath; |
||
33 | public $customerPasswordInputXpath; |
||
34 | public $customerButtonXpath; |
||
35 | |||
36 | public $billingFirstNameXpath; |
||
37 | public $billingLastNameXpath; |
||
38 | public $billingCompanyXpath; |
||
39 | public $billingEmailAddressXpath; |
||
40 | public $billingAddressXpath; |
||
41 | public $billingAddress2Xpath; |
||
42 | public $billingCityXpath; |
||
43 | /** |
||
44 | * @var string The Xpath string for the region_id OPTION to click. Must be sprintf() compatible |
||
45 | */ |
||
46 | public $billingRegionIdXpath; |
||
47 | public $billingPostCodeXpath; |
||
48 | /** |
||
49 | * @var string The Xpath string for the country OPTION to click. Must be sprintf() compatible |
||
50 | */ |
||
51 | public $billingCountryIdXpath; |
||
52 | public $billingTelephoneXpath; |
||
53 | public $billingFaxXpath; |
||
54 | |||
55 | public $useBillingAddressForShipping; |
||
56 | public $doNotUseBillingAddressForShipping; |
||
57 | |||
58 | public $billingContinueButtonXpath; |
||
59 | public $billingContinueCompletedXpath; |
||
60 | |||
61 | |||
62 | public $shippingFirstNameXpath; |
||
63 | public $shippingLastNameXpath; |
||
64 | public $shippingCompanyXpath; |
||
65 | public $shippingEmailAddressXpath; |
||
66 | public $shippingAddressXpath; |
||
67 | public $shippingAddress2Xpath; |
||
68 | public $shippingCityXpath; |
||
69 | /** |
||
70 | * @var string The Xpath string for the region_id OPTION to click. Must be sprintf() compatible |
||
71 | */ |
||
72 | public $shippingRegionIdXpath; |
||
73 | public $shippingPostCodeXpath; |
||
74 | /** |
||
75 | * @var string The Xpath string for the country OPTION to click. Must be sprintf() compatible |
||
76 | */ |
||
77 | public $shippingCountryIdXpath; |
||
78 | public $shippingTelephoneXpath; |
||
79 | public $shippingFaxXpath; |
||
80 | public $shippingContinueButtonXpath; |
||
81 | public $shippingContinueCompletedXpath; |
||
82 | public $shippingMethodContinueCompletedXpath; |
||
83 | |||
84 | public $shippingMethodContinueButtonXpath; |
||
85 | public $defaultShippingXpath; |
||
86 | |||
87 | public $paymentMethodContinueCompleteXpath; |
||
88 | |||
89 | public $paymentMethodContinueButtonXpath; |
||
90 | |||
91 | public $placeOrderButtonXpath; |
||
92 | |||
93 | public $orderReceivedCompleteXpath; |
||
94 | |||
95 | public $shippingMethodFormXpath; |
||
96 | |||
97 | public $passwordInputXpath; |
||
98 | public $confirmPasswordInputXpath; |
||
99 | |||
100 | /** |
||
101 | * This is a hard one. Each of the summary checkout products will be iterated over until they cannot be found. Having |
||
102 | * this work in a manner that gets all of the products, in all languages, in all themes, is quite difficult and |
||
103 | * so the Xpath selector needs to be one that can find each individual column with an incrementing iterator. |
||
104 | * |
||
105 | * @see Magium\Magento\Actions\Checkout\Extractors\CartSummary for an example on how this is done |
||
106 | * |
||
107 | * @var string |
||
108 | */ |
||
109 | |||
110 | public $cartSummaryCheckoutProductLoopPriceXpath; |
||
111 | public $cartSummaryCheckoutProductLoopNameXpath; |
||
112 | public $cartSummaryCheckoutProductLoopQtyXpath; |
||
113 | public $cartSummaryCheckoutProductLoopSubtotalXpath; |
||
114 | |||
115 | public $cartSummaryCheckoutSubTotal; |
||
116 | public $cartSummaryCheckoutTax; |
||
117 | public $cartSummaryCheckoutGrandTotal; |
||
118 | public $cartSummaryCheckoutShippingTotal; |
||
119 | |||
120 | public $billingNewAddressXpath; |
||
121 | public $shippingNewAddressXpath; |
||
122 | |||
123 | public $guaranteedPageLoadedElementDisplayedXpath = '//*[contains(concat(" ",normalize-space(@class)," ")," footer ")]'; |
||
124 | |||
125 | public $orderNumberExtractorXpath; |
||
126 | |||
127 | public function getOrderNumberExtractorXpath() |
||
131 | |||
132 | public function getGuaranteedPageLoadedElementDisplayedXpath() |
||
136 | |||
137 | /** |
||
138 | * @param mixed $guaranteedPageLoadedElementDisplayedXpath |
||
139 | */ |
||
140 | public function setGuaranteedPageLoadedElementDisplayedXpath($guaranteedPageLoadedElementDisplayedXpath) |
||
144 | |||
145 | /** |
||
146 | * @return string |
||
147 | */ |
||
148 | public function getBillingNewAddressXpath() |
||
152 | |||
153 | /** |
||
154 | * @return string |
||
155 | */ |
||
156 | public function getShippingNewAddressXpath() |
||
160 | |||
161 | /** |
||
162 | * @return mixed |
||
163 | */ |
||
164 | public function getDoNotUseBillingAddressForShipping() |
||
168 | |||
169 | /** |
||
170 | * @return mixed |
||
171 | */ |
||
172 | public function getUseBillingAddressForShipping() |
||
176 | |||
177 | /** |
||
178 | * @return string |
||
179 | */ |
||
180 | public function getBillingAddressDropdownXpath() |
||
184 | |||
185 | /** |
||
186 | * @return string |
||
187 | */ |
||
188 | public function getPasswordInputXpath() |
||
192 | |||
193 | /** |
||
194 | * @return string |
||
195 | */ |
||
196 | public function getConfirmPasswordInputXpath() |
||
200 | |||
201 | |||
202 | |||
203 | /** |
||
204 | * @return string |
||
205 | */ |
||
206 | public function getRegisterNewCustomerCheckoutButtonXpath() |
||
210 | |||
211 | /** |
||
212 | * @return string |
||
213 | */ |
||
214 | public function getCustomerEmailInputXpath() |
||
218 | |||
219 | /** |
||
220 | * @return string |
||
221 | */ |
||
222 | public function getCustomerPasswordInputXpath() |
||
226 | |||
227 | /** |
||
228 | * @return string |
||
229 | */ |
||
230 | public function getCustomerButtonXpath() |
||
234 | |||
235 | |||
236 | |||
237 | /** |
||
238 | * @return string |
||
239 | */ |
||
240 | public function getShippingMethodFormXpath() |
||
244 | |||
245 | /** |
||
246 | * @return string |
||
247 | */ |
||
248 | public function getOrderReceivedCompleteXpath() |
||
252 | |||
253 | |||
254 | /** |
||
255 | * @return string |
||
256 | */ |
||
257 | public function getPaymentMethodContinueButtonXpath() |
||
261 | |||
262 | /** |
||
263 | * @return string |
||
264 | */ |
||
265 | public function getShippingMethodContinueButtonXpath() |
||
269 | |||
270 | /** |
||
271 | * @return string |
||
272 | */ |
||
273 | public function getPlaceOrderButtonXpath() |
||
277 | |||
278 | |||
279 | /** |
||
280 | * @return string |
||
281 | */ |
||
282 | public function getPaymentMethodContinueCompleteXpath() |
||
286 | |||
287 | |||
288 | public function getDefaultShippingXpath() |
||
292 | |||
293 | /** |
||
294 | * @return string |
||
295 | */ |
||
296 | public function getShippingMethodContinueCompletedXpath() |
||
300 | |||
301 | /** |
||
302 | * @return string |
||
303 | */ |
||
304 | public function getShippingFirstNameXpath() |
||
308 | |||
309 | /** |
||
310 | * @param string $shippinFirstNameXpath |
||
|
|||
311 | */ |
||
312 | public function setShippingFirstNameXpath($shippingFirstNameXpath) |
||
316 | |||
317 | /** |
||
318 | * @return string |
||
319 | */ |
||
320 | public function getShippingLastNameXpath() |
||
324 | |||
325 | /** |
||
326 | * @param string $shippingLastNameXpath |
||
327 | */ |
||
328 | public function setShippingLastNameXpath($shippingLastNameXpath) |
||
332 | |||
333 | /** |
||
334 | * @return string |
||
335 | */ |
||
336 | public function getShippingCompanyXpath() |
||
340 | |||
341 | /** |
||
342 | * @param string $shippingCompanyXpath |
||
343 | */ |
||
344 | public function setShippingCompanyXpath($shippingCompanyXpath) |
||
348 | |||
349 | /** |
||
350 | * @return string |
||
351 | */ |
||
352 | public function getShippingEmailAddressXpath() |
||
356 | |||
357 | /** |
||
358 | * @param string $shippingEmailAddressXpath |
||
359 | */ |
||
360 | public function setShippingEmailAddressXpath($shippingEmailAddressXpath) |
||
364 | |||
365 | /** |
||
366 | * @return string |
||
367 | */ |
||
368 | public function getShippingAddressXpath() |
||
372 | |||
373 | /** |
||
374 | * @param string $shippingAddressXpath |
||
375 | */ |
||
376 | public function setShippingAddressXpath($shippingAddressXpath) |
||
380 | |||
381 | /** |
||
382 | * @return string |
||
383 | */ |
||
384 | public function getShippingAddress2Xpath() |
||
388 | |||
389 | /** |
||
390 | * @param string $shippingAddress2Xpath |
||
391 | */ |
||
392 | public function setShippingAddress2Xpath($shippingAddress2Xpath) |
||
396 | |||
397 | /** |
||
398 | * @return string |
||
399 | */ |
||
400 | public function getShippingCityXpath() |
||
404 | |||
405 | /** |
||
406 | * @param string $shippingCityXpath |
||
407 | */ |
||
408 | public function setShippingCityXpath($shippingCityXpath) |
||
412 | |||
413 | /** |
||
414 | * @return string |
||
415 | */ |
||
416 | public function getShippingRegionIdXpath($region) |
||
421 | |||
422 | /** |
||
423 | * @param string $shippingRegionIdXpath |
||
424 | */ |
||
425 | public function setShippingRegionIdXpath($shippingRegionIdXpath) |
||
429 | |||
430 | /** |
||
431 | * @return string |
||
432 | */ |
||
433 | public function getShippingPostCodeXpath() |
||
437 | |||
438 | /** |
||
439 | * @param string $shippingPostCodeXpath |
||
440 | */ |
||
441 | public function setShippingPostCodeXpath($shippingPostCodeXpath) |
||
445 | |||
446 | /** |
||
447 | * @return string |
||
448 | */ |
||
449 | public function getShippingCountryIdXpath($country) |
||
454 | |||
455 | /** |
||
456 | * @param string $shippingCountryIdXpath |
||
457 | */ |
||
458 | public function setShippingCountryIdXpath($shippingCountryIdXpath) |
||
462 | |||
463 | /** |
||
464 | * @return string |
||
465 | */ |
||
466 | public function getShippingTelephoneXpath() |
||
470 | |||
471 | /** |
||
472 | * @param string $shippingTelephoneXpath |
||
473 | */ |
||
474 | public function setShippingTelephoneXpath($shippingTelephoneXpath) |
||
478 | |||
479 | /** |
||
480 | * @return string |
||
481 | */ |
||
482 | public function getShippingFaxXpath() |
||
486 | |||
487 | /** |
||
488 | * @param string $shippingFaxXpath |
||
489 | */ |
||
490 | public function setShippingFaxXpath($shippingFaxXpath) |
||
494 | |||
495 | /** |
||
496 | * @return string |
||
497 | */ |
||
498 | public function getShippingContinueButtonXpath() |
||
502 | |||
503 | /** |
||
504 | * @param string $shippingContinueButtonXpath |
||
505 | */ |
||
506 | public function setShippingContinueButtonXpath($shippingContinueButtonXpath) |
||
510 | |||
511 | /** |
||
512 | * @return string |
||
513 | */ |
||
514 | public function getShippingContinueCompletedXpath() |
||
518 | |||
519 | /** |
||
520 | * @param string $shippingContinueCompletedXpath |
||
521 | */ |
||
522 | public function setShippingContinueCompletedXpath($shippingContinueCompletedXpath) |
||
526 | |||
527 | public function getBillingContinueCompletedXpath() |
||
531 | |||
532 | public function getContinueButtonXpath() |
||
536 | |||
537 | public function getGuestCheckoutButtonXpath() |
||
541 | |||
542 | /** |
||
543 | * @return string |
||
544 | */ |
||
545 | public function getBillingFirstNameXpath() |
||
549 | |||
550 | /** |
||
551 | * @return string |
||
552 | */ |
||
553 | public function getBillingLastNameXpath() |
||
557 | |||
558 | /** |
||
559 | * @return string |
||
560 | */ |
||
561 | public function getBillingCompanyXpath() |
||
565 | |||
566 | /** |
||
567 | * @return string |
||
568 | */ |
||
569 | public function getBillingEmailAddressXpath() |
||
573 | |||
574 | /** |
||
575 | * @return string |
||
576 | */ |
||
577 | public function getBillingAddressXpath() |
||
581 | |||
582 | /** |
||
583 | * @return string |
||
584 | */ |
||
585 | public function getBillingAddress2Xpath() |
||
589 | |||
590 | /** |
||
591 | * @return string |
||
592 | */ |
||
593 | public function getBillingCityXpath() |
||
597 | |||
598 | /** |
||
599 | * @return string |
||
600 | */ |
||
601 | public function getBillingRegionIdXpath($region) |
||
606 | |||
607 | /** |
||
608 | * @return string |
||
609 | */ |
||
610 | public function getBillingPostCodeXpath() |
||
614 | |||
615 | /** |
||
616 | * @return string |
||
617 | */ |
||
618 | public function getBillingCountryIdXpath($country) |
||
623 | |||
624 | /** |
||
625 | * @return string |
||
626 | */ |
||
627 | public function getBillingTelephoneXpath() |
||
631 | |||
632 | /** |
||
633 | * @return string |
||
634 | */ |
||
635 | public function getBillingFaxXpath() |
||
639 | |||
640 | /** |
||
641 | * @return string |
||
642 | */ |
||
643 | public function getBillingContinueButtonXpath() |
||
647 | |||
648 | /** |
||
649 | * @return string |
||
650 | */ |
||
651 | public function getCartSummaryCheckoutSubTotal() |
||
655 | |||
656 | /** |
||
657 | * @return string |
||
658 | */ |
||
659 | public function getCartSummaryCheckoutTax() |
||
663 | |||
664 | /** |
||
665 | * @return string |
||
666 | */ |
||
667 | public function getCartSummaryCheckoutGrandTotal() |
||
671 | |||
672 | /** |
||
673 | * @return string |
||
674 | */ |
||
675 | public function getCartSummaryCheckoutShippingTotal() |
||
679 | |||
680 | |||
681 | |||
682 | /** |
||
683 | * @return string |
||
684 | */ |
||
685 | public function getCartSummaryCheckoutProductLoopPriceXpath($itemCount) |
||
690 | |||
691 | /** |
||
692 | * @return string |
||
693 | */ |
||
694 | public function getCartSummaryCheckoutProductLoopNameXpath($itemCount) |
||
699 | |||
700 | /** |
||
701 | * @return string |
||
702 | */ |
||
703 | public function getCartSummaryCheckoutProductLoopQtyXpath($itemCount) |
||
708 | |||
709 | /** |
||
710 | * @return string |
||
711 | */ |
||
712 | public function getCartSummaryCheckoutProductLoopSubtotalXpath($itemCount) |
||
717 | |||
718 | } |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.