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 | * Gets as isTestMode |
||
| 58 | * |
||
| 59 | * @return boolean |
||
| 60 | */ |
||
| 61 | public function getIsTestMode() |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Sets a new isTestMode |
||
| 68 | * |
||
| 69 | * @param boolean $isTestMode |
||
| 70 | * @return self |
||
| 71 | */ |
||
| 72 | public function setIsTestMode($isTestMode) |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Adds as processor |
||
| 80 | * |
||
| 81 | * @return self |
||
| 82 | * @param \net\authorize\api\contract\v1\ProcessorType $processor |
||
| 83 | */ |
||
| 84 | public function addToProcessors(\net\authorize\api\contract\v1\ProcessorType $processor) |
||
| 89 | |||
| 90 | /** |
||
| 91 | * isset processors |
||
| 92 | * |
||
| 93 | * @param scalar $index |
||
| 94 | * @return boolean |
||
| 95 | */ |
||
| 96 | public function issetProcessors($index) |
||
| 100 | |||
| 101 | /** |
||
| 102 | * unset processors |
||
| 103 | * |
||
| 104 | * @param scalar $index |
||
| 105 | * @return void |
||
| 106 | */ |
||
| 107 | public function unsetProcessors($index) |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Gets as processors |
||
| 114 | * |
||
| 115 | * @return \net\authorize\api\contract\v1\ProcessorType[] |
||
| 116 | */ |
||
| 117 | public function getProcessors() |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Sets a new processors |
||
| 124 | * |
||
| 125 | * @param \net\authorize\api\contract\v1\ProcessorType[] $processors |
||
| 126 | * @return self |
||
| 127 | */ |
||
| 128 | public function setProcessors(array $processors) |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Gets as merchantName |
||
| 136 | * |
||
| 137 | * @return string |
||
| 138 | */ |
||
| 139 | public function getMerchantName() |
||
| 143 | |||
| 144 | /** |
||
| 145 | * Sets a new merchantName |
||
| 146 | * |
||
| 147 | * @param string $merchantName |
||
| 148 | * @return self |
||
| 149 | */ |
||
| 150 | public function setMerchantName($merchantName) |
||
| 155 | |||
| 156 | /** |
||
| 157 | * Gets as gatewayId |
||
| 158 | * |
||
| 159 | * @return string |
||
| 160 | */ |
||
| 161 | public function getGatewayId() |
||
| 165 | |||
| 166 | /** |
||
| 167 | * Sets a new gatewayId |
||
| 168 | * |
||
| 169 | * @param string $gatewayId |
||
| 170 | * @return self |
||
| 171 | */ |
||
| 172 | public function setGatewayId($gatewayId) |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Adds as marketType |
||
| 180 | * |
||
| 181 | * @return self |
||
| 182 | * @param string $marketType |
||
| 183 | */ |
||
| 184 | public function addToMarketTypes($marketType) |
||
| 189 | |||
| 190 | /** |
||
| 191 | * isset marketTypes |
||
| 192 | * |
||
| 193 | * @param scalar $index |
||
| 194 | * @return boolean |
||
| 195 | */ |
||
| 196 | public function issetMarketTypes($index) |
||
| 200 | |||
| 201 | /** |
||
| 202 | * unset marketTypes |
||
| 203 | * |
||
| 204 | * @param scalar $index |
||
| 205 | * @return void |
||
| 206 | */ |
||
| 207 | public function unsetMarketTypes($index) |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Gets as marketTypes |
||
| 214 | * |
||
| 215 | * @return string[] |
||
| 216 | */ |
||
| 217 | public function getMarketTypes() |
||
| 221 | |||
| 222 | /** |
||
| 223 | * Sets a new marketTypes |
||
| 224 | * |
||
| 225 | * @param string $marketTypes |
||
| 226 | * @return self |
||
| 227 | */ |
||
| 228 | public function setMarketTypes(array $marketTypes) |
||
| 233 | |||
| 234 | /** |
||
| 235 | * Adds as productCode |
||
| 236 | * |
||
| 237 | * @return self |
||
| 238 | * @param string $productCode |
||
| 239 | */ |
||
| 240 | public function addToProductCodes($productCode) |
||
| 245 | |||
| 246 | /** |
||
| 247 | * isset productCodes |
||
| 248 | * |
||
| 249 | * @param scalar $index |
||
| 250 | * @return boolean |
||
| 251 | */ |
||
| 252 | public function issetProductCodes($index) |
||
| 256 | |||
| 257 | /** |
||
| 258 | * unset productCodes |
||
| 259 | * |
||
| 260 | * @param scalar $index |
||
| 261 | * @return void |
||
| 262 | */ |
||
| 263 | public function unsetProductCodes($index) |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Gets as productCodes |
||
| 270 | * |
||
| 271 | * @return string[] |
||
| 272 | */ |
||
| 273 | public function getProductCodes() |
||
| 277 | |||
| 278 | /** |
||
| 279 | * Sets a new productCodes |
||
| 280 | * |
||
| 281 | * @param string $productCodes |
||
| 282 | * @return self |
||
| 283 | */ |
||
| 284 | public function setProductCodes(array $productCodes) |
||
| 289 | |||
| 290 | /** |
||
| 291 | * Adds as paymentMethod |
||
| 292 | * |
||
| 293 | * @return self |
||
| 294 | * @param string $paymentMethod |
||
| 295 | */ |
||
| 296 | public function addToPaymentMethods($paymentMethod) |
||
| 301 | |||
| 302 | /** |
||
| 303 | * isset paymentMethods |
||
| 304 | * |
||
| 305 | * @param scalar $index |
||
| 306 | * @return boolean |
||
| 307 | */ |
||
| 308 | public function issetPaymentMethods($index) |
||
| 312 | |||
| 313 | /** |
||
| 314 | * unset paymentMethods |
||
| 315 | * |
||
| 316 | * @param scalar $index |
||
| 317 | * @return void |
||
| 318 | */ |
||
| 319 | public function unsetPaymentMethods($index) |
||
| 323 | |||
| 324 | /** |
||
| 325 | * Gets as paymentMethods |
||
| 326 | * |
||
| 327 | * @return string[] |
||
| 328 | */ |
||
| 329 | public function getPaymentMethods() |
||
| 333 | |||
| 334 | /** |
||
| 335 | * Sets a new paymentMethods |
||
| 336 | * |
||
| 337 | * @param string $paymentMethods |
||
| 338 | * @return self |
||
| 339 | */ |
||
| 340 | public function setPaymentMethods(array $paymentMethods) |
||
| 345 | |||
| 346 | /** |
||
| 347 | * Adds as currency |
||
| 348 | * |
||
| 349 | * @return self |
||
| 350 | * @param string $currency |
||
| 351 | */ |
||
| 352 | public function addToCurrencies($currency) |
||
| 357 | |||
| 358 | /** |
||
| 359 | * isset currencies |
||
| 360 | * |
||
| 361 | * @param scalar $index |
||
| 362 | * @return boolean |
||
| 363 | */ |
||
| 364 | public function issetCurrencies($index) |
||
| 368 | |||
| 369 | /** |
||
| 370 | * unset currencies |
||
| 371 | * |
||
| 372 | * @param scalar $index |
||
| 373 | * @return void |
||
| 374 | */ |
||
| 375 | public function unsetCurrencies($index) |
||
| 379 | |||
| 380 | /** |
||
| 381 | * Gets as currencies |
||
| 382 | * |
||
| 383 | * @return string[] |
||
| 384 | */ |
||
| 385 | public function getCurrencies() |
||
| 389 | |||
| 390 | /** |
||
| 391 | * Sets a new currencies |
||
| 392 | * |
||
| 393 | * @param string $currencies |
||
| 394 | * @return self |
||
| 395 | */ |
||
| 396 | public function setCurrencies(array $currencies) |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Gets as publicClientKey |
||
| 404 | * |
||
| 405 | * @return string |
||
| 406 | */ |
||
| 407 | public function getPublicClientKey() |
||
| 411 | |||
| 412 | /** |
||
| 413 | * Sets a new publicClientKey |
||
| 414 | * |
||
| 415 | * @param string $publicClientKey |
||
| 416 | * @return self |
||
| 417 | */ |
||
| 418 | public function setPublicClientKey($publicClientKey) |
||
| 423 | |||
| 424 | |||
| 425 | // Json Set Code |
||
| 426 | public function set($data) |
||
| 472 | |||
| 473 | } |
||
| 474 | |||
| 475 |