Complex classes like GetMerchantDetailsResponse 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 GetMerchantDetailsResponse, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
8 | class GetMerchantDetailsResponse extends ANetApiResponseType |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @property boolean $isTestMode |
||
13 | */ |
||
14 | private $isTestMode = null; |
||
15 | |||
16 | /** |
||
17 | * @property \net\authorize\api\contract\v1\ProcessorType[] $processors |
||
18 | */ |
||
19 | private $processors = null; |
||
20 | |||
21 | /** |
||
22 | * @property string $merchantName |
||
23 | */ |
||
24 | private $merchantName = null; |
||
25 | |||
26 | /** |
||
27 | * @property string $gatewayId |
||
28 | */ |
||
29 | private $gatewayId = null; |
||
30 | |||
31 | /** |
||
32 | * @property string[] $marketTypes |
||
33 | */ |
||
34 | private $marketTypes = null; |
||
35 | |||
36 | /** |
||
37 | * @property string[] $productCodes |
||
38 | */ |
||
39 | private $productCodes = null; |
||
40 | |||
41 | /** |
||
42 | * @property string[] $paymentMethods |
||
43 | */ |
||
44 | private $paymentMethods = null; |
||
45 | |||
46 | /** |
||
47 | * @property string[] $currencies |
||
48 | */ |
||
49 | private $currencies = null; |
||
50 | |||
51 | /** |
||
52 | * @property string $publicClientKey |
||
53 | */ |
||
54 | private $publicClientKey = null; |
||
55 | |||
56 | /** |
||
57 | * @property \net\authorize\api\contract\v1\CustomerAddressType |
||
58 | * $businessInformation |
||
59 | */ |
||
60 | private $businessInformation = null; |
||
61 | |||
62 | /** |
||
63 | * @property string $merchantTimeZone |
||
64 | */ |
||
65 | private $merchantTimeZone = null; |
||
66 | |||
67 | /** |
||
68 | * @property \net\authorize\api\contract\v1\ContactDetailType[] $contactDetails |
||
69 | */ |
||
70 | private $contactDetails = null; |
||
71 | |||
72 | /** |
||
73 | * Gets as isTestMode |
||
74 | * |
||
75 | * @return boolean |
||
76 | */ |
||
77 | public function getIsTestMode() |
||
81 | |||
82 | /** |
||
83 | * Sets a new isTestMode |
||
84 | * |
||
85 | * @param boolean $isTestMode |
||
86 | * @return self |
||
87 | */ |
||
88 | public function setIsTestMode($isTestMode) |
||
93 | |||
94 | /** |
||
95 | * Adds as processor |
||
96 | * |
||
97 | * @return self |
||
98 | * @param \net\authorize\api\contract\v1\ProcessorType $processor |
||
99 | */ |
||
100 | public function addToProcessors(\net\authorize\api\contract\v1\ProcessorType $processor) |
||
105 | |||
106 | /** |
||
107 | * isset processors |
||
108 | * |
||
109 | * @param scalar $index |
||
110 | * @return boolean |
||
111 | */ |
||
112 | public function issetProcessors($index) |
||
116 | |||
117 | /** |
||
118 | * unset processors |
||
119 | * |
||
120 | * @param scalar $index |
||
121 | * @return void |
||
122 | */ |
||
123 | public function unsetProcessors($index) |
||
127 | |||
128 | /** |
||
129 | * Gets as processors |
||
130 | * |
||
131 | * @return \net\authorize\api\contract\v1\ProcessorType[] |
||
132 | */ |
||
133 | public function getProcessors() |
||
137 | |||
138 | /** |
||
139 | * Sets a new processors |
||
140 | * |
||
141 | * @param \net\authorize\api\contract\v1\ProcessorType[] $processors |
||
142 | * @return self |
||
143 | */ |
||
144 | public function setProcessors(array $processors) |
||
149 | |||
150 | /** |
||
151 | * Gets as merchantName |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | public function getMerchantName() |
||
159 | |||
160 | /** |
||
161 | * Sets a new merchantName |
||
162 | * |
||
163 | * @param string $merchantName |
||
164 | * @return self |
||
165 | */ |
||
166 | public function setMerchantName($merchantName) |
||
171 | |||
172 | /** |
||
173 | * Gets as gatewayId |
||
174 | * |
||
175 | * @return string |
||
176 | */ |
||
177 | public function getGatewayId() |
||
181 | |||
182 | /** |
||
183 | * Sets a new gatewayId |
||
184 | * |
||
185 | * @param string $gatewayId |
||
186 | * @return self |
||
187 | */ |
||
188 | public function setGatewayId($gatewayId) |
||
193 | |||
194 | /** |
||
195 | * Adds as marketType |
||
196 | * |
||
197 | * @return self |
||
198 | * @param string $marketType |
||
199 | */ |
||
200 | public function addToMarketTypes($marketType) |
||
205 | |||
206 | /** |
||
207 | * isset marketTypes |
||
208 | * |
||
209 | * @param scalar $index |
||
210 | * @return boolean |
||
211 | */ |
||
212 | public function issetMarketTypes($index) |
||
216 | |||
217 | /** |
||
218 | * unset marketTypes |
||
219 | * |
||
220 | * @param scalar $index |
||
221 | * @return void |
||
222 | */ |
||
223 | public function unsetMarketTypes($index) |
||
227 | |||
228 | /** |
||
229 | * Gets as marketTypes |
||
230 | * |
||
231 | * @return string[] |
||
232 | */ |
||
233 | public function getMarketTypes() |
||
237 | |||
238 | /** |
||
239 | * Sets a new marketTypes |
||
240 | * |
||
241 | * @param string $marketTypes |
||
242 | * @return self |
||
243 | */ |
||
244 | public function setMarketTypes(array $marketTypes) |
||
249 | |||
250 | /** |
||
251 | * Adds as productCode |
||
252 | * |
||
253 | * @return self |
||
254 | * @param string $productCode |
||
255 | */ |
||
256 | public function addToProductCodes($productCode) |
||
261 | |||
262 | /** |
||
263 | * isset productCodes |
||
264 | * |
||
265 | * @param scalar $index |
||
266 | * @return boolean |
||
267 | */ |
||
268 | public function issetProductCodes($index) |
||
272 | |||
273 | /** |
||
274 | * unset productCodes |
||
275 | * |
||
276 | * @param scalar $index |
||
277 | * @return void |
||
278 | */ |
||
279 | public function unsetProductCodes($index) |
||
283 | |||
284 | /** |
||
285 | * Gets as productCodes |
||
286 | * |
||
287 | * @return string[] |
||
288 | */ |
||
289 | public function getProductCodes() |
||
293 | |||
294 | /** |
||
295 | * Sets a new productCodes |
||
296 | * |
||
297 | * @param string $productCodes |
||
298 | * @return self |
||
299 | */ |
||
300 | public function setProductCodes(array $productCodes) |
||
305 | |||
306 | /** |
||
307 | * Adds as paymentMethod |
||
308 | * |
||
309 | * @return self |
||
310 | * @param string $paymentMethod |
||
311 | */ |
||
312 | public function addToPaymentMethods($paymentMethod) |
||
317 | |||
318 | /** |
||
319 | * isset paymentMethods |
||
320 | * |
||
321 | * @param scalar $index |
||
322 | * @return boolean |
||
323 | */ |
||
324 | public function issetPaymentMethods($index) |
||
328 | |||
329 | /** |
||
330 | * unset paymentMethods |
||
331 | * |
||
332 | * @param scalar $index |
||
333 | * @return void |
||
334 | */ |
||
335 | public function unsetPaymentMethods($index) |
||
339 | |||
340 | /** |
||
341 | * Gets as paymentMethods |
||
342 | * |
||
343 | * @return string[] |
||
344 | */ |
||
345 | public function getPaymentMethods() |
||
349 | |||
350 | /** |
||
351 | * Sets a new paymentMethods |
||
352 | * |
||
353 | * @param string $paymentMethods |
||
354 | * @return self |
||
355 | */ |
||
356 | public function setPaymentMethods(array $paymentMethods) |
||
361 | |||
362 | /** |
||
363 | * Adds as currency |
||
364 | * |
||
365 | * @return self |
||
366 | * @param string $currency |
||
367 | */ |
||
368 | public function addToCurrencies($currency) |
||
373 | |||
374 | /** |
||
375 | * isset currencies |
||
376 | * |
||
377 | * @param scalar $index |
||
378 | * @return boolean |
||
379 | */ |
||
380 | public function issetCurrencies($index) |
||
384 | |||
385 | /** |
||
386 | * unset currencies |
||
387 | * |
||
388 | * @param scalar $index |
||
389 | * @return void |
||
390 | */ |
||
391 | public function unsetCurrencies($index) |
||
395 | |||
396 | /** |
||
397 | * Gets as currencies |
||
398 | * |
||
399 | * @return string[] |
||
400 | */ |
||
401 | public function getCurrencies() |
||
405 | |||
406 | /** |
||
407 | * Sets a new currencies |
||
408 | * |
||
409 | * @param string $currencies |
||
410 | * @return self |
||
411 | */ |
||
412 | public function setCurrencies(array $currencies) |
||
417 | |||
418 | /** |
||
419 | * Gets as publicClientKey |
||
420 | * |
||
421 | * @return string |
||
422 | */ |
||
423 | public function getPublicClientKey() |
||
427 | |||
428 | /** |
||
429 | * Sets a new publicClientKey |
||
430 | * |
||
431 | * @param string $publicClientKey |
||
432 | * @return self |
||
433 | */ |
||
434 | public function setPublicClientKey($publicClientKey) |
||
439 | |||
440 | /** |
||
441 | * Gets as businessInformation |
||
442 | * |
||
443 | * @return \net\authorize\api\contract\v1\CustomerAddressType |
||
444 | */ |
||
445 | public function getBusinessInformation() |
||
449 | |||
450 | /** |
||
451 | * Sets a new businessInformation |
||
452 | * |
||
453 | * @param \net\authorize\api\contract\v1\CustomerAddressType $businessInformation |
||
454 | * @return self |
||
455 | */ |
||
456 | public function setBusinessInformation(\net\authorize\api\contract\v1\CustomerAddressType $businessInformation) |
||
461 | |||
462 | /** |
||
463 | * Gets as merchantTimeZone |
||
464 | * |
||
465 | * @return string |
||
466 | */ |
||
467 | public function getMerchantTimeZone() |
||
471 | |||
472 | /** |
||
473 | * Sets a new merchantTimeZone |
||
474 | * |
||
475 | * @param string $merchantTimeZone |
||
476 | * @return self |
||
477 | */ |
||
478 | public function setMerchantTimeZone($merchantTimeZone) |
||
483 | |||
484 | /** |
||
485 | * Adds as contactDetail |
||
486 | * |
||
487 | * @return self |
||
488 | * @param \net\authorize\api\contract\v1\ContactDetailType $contactDetail |
||
489 | */ |
||
490 | public function addToContactDetails(\net\authorize\api\contract\v1\ContactDetailType $contactDetail) |
||
495 | |||
496 | /** |
||
497 | * isset contactDetails |
||
498 | * |
||
499 | * @param scalar $index |
||
500 | * @return boolean |
||
501 | */ |
||
502 | public function issetContactDetails($index) |
||
506 | |||
507 | /** |
||
508 | * unset contactDetails |
||
509 | * |
||
510 | * @param scalar $index |
||
511 | * @return void |
||
512 | */ |
||
513 | public function unsetContactDetails($index) |
||
517 | |||
518 | /** |
||
519 | * Gets as contactDetails |
||
520 | * |
||
521 | * @return \net\authorize\api\contract\v1\ContactDetailType[] |
||
522 | */ |
||
523 | public function getContactDetails() |
||
527 | |||
528 | /** |
||
529 | * Sets a new contactDetails |
||
530 | * |
||
531 | * @param \net\authorize\api\contract\v1\ContactDetailType[] $contactDetails |
||
532 | * @return self |
||
533 | */ |
||
534 | public function setContactDetails(array $contactDetails) |
||
539 | |||
540 | |||
541 | // Json Set Code |
||
542 | public function set($data) |
||
588 | |||
589 | } |
||
590 | |||
591 |