Complex classes like AbstractRequestContainer 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 AbstractRequestContainer, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 10 | abstract class AbstractRequestContainer extends AbstractContainer |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var int merchant id |
||
| 14 | */ |
||
| 15 | protected $mid; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var int |
||
| 19 | */ |
||
| 20 | protected $aid; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var int payment portal id |
||
| 24 | */ |
||
| 25 | protected $portalid; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string payment portal id as md5 |
||
| 29 | */ |
||
| 30 | protected $key; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string version of the the payone api defaults to 3.8 |
||
| 34 | */ |
||
| 35 | protected $api_version; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var string test or live mode |
||
| 39 | */ |
||
| 40 | protected $mode; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var string payone query name (e.g. preauthorization, authorization...) |
||
| 44 | */ |
||
| 45 | protected $request; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string encoding (ISO 8859-1 or UTF-8) |
||
| 49 | */ |
||
| 50 | protected $encoding; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * name of the solution-partner (company) |
||
| 54 | * |
||
| 55 | * @var string |
||
| 56 | */ |
||
| 57 | protected $solution_name; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * version of the solution-partner's app / extension / plugin / etc.. |
||
| 61 | * |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | protected $solution_version; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * system-name |
||
| 68 | * |
||
| 69 | * @var string |
||
| 70 | */ |
||
| 71 | protected $integrator_name; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * system-version |
||
| 75 | * |
||
| 76 | * @var string |
||
| 77 | */ |
||
| 78 | protected $integrator_version; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var string |
||
| 82 | */ |
||
| 83 | protected $language; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var string |
||
| 87 | */ |
||
| 88 | protected $hash; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @var string |
||
| 92 | */ |
||
| 93 | protected $responsetype; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var array |
||
| 97 | */ |
||
| 98 | protected $it; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @var array |
||
| 102 | */ |
||
| 103 | protected $id; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @var array |
||
| 107 | */ |
||
| 108 | protected $pr; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @var array |
||
| 112 | */ |
||
| 113 | protected $no; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @var array |
||
| 117 | */ |
||
| 118 | protected $de; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @var array |
||
| 122 | */ |
||
| 123 | protected $va; |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @var string |
||
| 127 | */ |
||
| 128 | protected $email; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @param string $encoding |
||
| 132 | * |
||
| 133 | * @return $this |
||
| 134 | */ |
||
| 135 | public function setEncoding($encoding) |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @return string |
||
| 144 | */ |
||
| 145 | public function getEncoding() |
||
| 149 | |||
| 150 | /** |
||
| 151 | * @param string $key |
||
| 152 | * |
||
| 153 | * @return $this |
||
| 154 | */ |
||
| 155 | public function setKey($key) |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @return string |
||
| 164 | */ |
||
| 165 | public function getKey() |
||
| 169 | |||
| 170 | /** |
||
| 171 | * @param string $api_version |
||
| 172 | * |
||
| 173 | * @return $this |
||
| 174 | */ |
||
| 175 | public function setApiVersion($api_version) |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @return string |
||
| 184 | */ |
||
| 185 | public function getApiVersion() |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @param int $mid |
||
| 192 | * |
||
| 193 | * @return $this |
||
| 194 | */ |
||
| 195 | public function setMid($mid) |
||
| 201 | |||
| 202 | /** |
||
| 203 | * @return int |
||
| 204 | */ |
||
| 205 | public function getMid() |
||
| 209 | |||
| 210 | /** |
||
| 211 | * @param string $mode |
||
| 212 | * |
||
| 213 | * @return $this |
||
| 214 | */ |
||
| 215 | public function setMode($mode) |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @return string |
||
| 224 | */ |
||
| 225 | public function getMode() |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @param int $portalid |
||
| 232 | * |
||
| 233 | * @return $this |
||
| 234 | */ |
||
| 235 | public function setPortalid($portalid) |
||
| 241 | |||
| 242 | /** |
||
| 243 | * @return int |
||
| 244 | */ |
||
| 245 | public function getPortalid() |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @param string $request |
||
| 252 | * |
||
| 253 | * @return $this |
||
| 254 | */ |
||
| 255 | public function setRequest($request) |
||
| 261 | |||
| 262 | /** |
||
| 263 | * @return string |
||
| 264 | */ |
||
| 265 | public function getRequest() |
||
| 269 | |||
| 270 | /** |
||
| 271 | * set the system-Name |
||
| 272 | * |
||
| 273 | * @param string $integrator_name |
||
| 274 | * |
||
| 275 | * @return $this |
||
| 276 | */ |
||
| 277 | public function setIntegratorName($integrator_name) |
||
| 283 | |||
| 284 | /** |
||
| 285 | * @return string |
||
| 286 | */ |
||
| 287 | public function getIntegratorName() |
||
| 291 | |||
| 292 | /** |
||
| 293 | * set the system-version |
||
| 294 | * |
||
| 295 | * @param string $integrator_version |
||
| 296 | * |
||
| 297 | * @return $this |
||
| 298 | */ |
||
| 299 | public function setIntegratorVersion($integrator_version) |
||
| 305 | |||
| 306 | /** |
||
| 307 | * @return string |
||
| 308 | */ |
||
| 309 | public function getIntegratorVersion() |
||
| 313 | |||
| 314 | /** |
||
| 315 | * set the name of the solution-partner (company) |
||
| 316 | * |
||
| 317 | * @param string $solution_name |
||
| 318 | * |
||
| 319 | * @return $this |
||
| 320 | */ |
||
| 321 | public function setSolutionName($solution_name) |
||
| 327 | |||
| 328 | /** |
||
| 329 | * @return string |
||
| 330 | */ |
||
| 331 | public function getSolutionName() |
||
| 335 | |||
| 336 | /** |
||
| 337 | * set the version of the solution-partner's app / extension / plugin / etc.. |
||
| 338 | * |
||
| 339 | * @param string $solution_version |
||
| 340 | * |
||
| 341 | * @return $this |
||
| 342 | */ |
||
| 343 | public function setSolutionVersion($solution_version) |
||
| 349 | |||
| 350 | /** |
||
| 351 | * @return string |
||
| 352 | */ |
||
| 353 | public function getSolutionVersion() |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @return int |
||
| 360 | */ |
||
| 361 | public function getAid() |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @param int $aid |
||
| 368 | * |
||
| 369 | * @return $this |
||
| 370 | */ |
||
| 371 | public function setAid($aid) |
||
| 377 | |||
| 378 | /** |
||
| 379 | * @return string |
||
| 380 | */ |
||
| 381 | public function getLanguage() |
||
| 385 | |||
| 386 | /** |
||
| 387 | * @param string $language |
||
| 388 | * |
||
| 389 | * @return $this |
||
| 390 | */ |
||
| 391 | public function setLanguage($language) |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @param string $hash |
||
| 400 | * |
||
| 401 | * @return $this |
||
| 402 | */ |
||
| 403 | public function setHash($hash) |
||
| 409 | |||
| 410 | /** |
||
| 411 | * @return string |
||
| 412 | */ |
||
| 413 | public function getHash() |
||
| 417 | |||
| 418 | /** |
||
| 419 | * @return string |
||
| 420 | */ |
||
| 421 | public function getResponsetype() |
||
| 425 | |||
| 426 | /** |
||
| 427 | * @param string $responsetype |
||
| 428 | * |
||
| 429 | * @return $this |
||
| 430 | */ |
||
| 431 | public function setResponsetype($responsetype) |
||
| 437 | |||
| 438 | /** |
||
| 439 | * @return array |
||
| 440 | */ |
||
| 441 | public function getIt(): array |
||
| 445 | |||
| 446 | /** |
||
| 447 | * @param array $it |
||
| 448 | */ |
||
| 449 | public function setIt(array $it): void |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @return array |
||
| 456 | */ |
||
| 457 | public function getId(): array |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @param array $id |
||
| 464 | */ |
||
| 465 | public function setId(array $id): void |
||
| 469 | |||
| 470 | /** |
||
| 471 | * @return array |
||
| 472 | */ |
||
| 473 | public function getPr(): array |
||
| 477 | |||
| 478 | /** |
||
| 479 | * @param array $pr |
||
| 480 | */ |
||
| 481 | public function setPr(array $pr): void |
||
| 485 | |||
| 486 | /** |
||
| 487 | * @return array |
||
| 488 | */ |
||
| 489 | public function getNo(): array |
||
| 493 | |||
| 494 | /** |
||
| 495 | * @param array $no |
||
| 496 | */ |
||
| 497 | public function setNo(array $no): void |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @return array |
||
| 504 | */ |
||
| 505 | public function getDe(): array |
||
| 509 | |||
| 510 | /** |
||
| 511 | * @param array $de |
||
| 512 | */ |
||
| 513 | public function setDe(array $de): void |
||
| 517 | |||
| 518 | /** |
||
| 519 | * @return array |
||
| 520 | */ |
||
| 521 | public function getVa(): array |
||
| 525 | |||
| 526 | /** |
||
| 527 | * @param array $va |
||
| 528 | */ |
||
| 529 | public function setVa(array $va): void |
||
| 533 | |||
| 534 | /** |
||
| 535 | * @return string |
||
| 536 | */ |
||
| 537 | public function getEmail(): string |
||
| 541 | |||
| 542 | /** |
||
| 543 | * @param string $email |
||
| 544 | */ |
||
| 545 | public function setEmail(string $email): void |
||
| 549 | } |
||
| 550 |