Complex classes like addShipment 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 addShipment, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 5 | class addShipment |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string |
||
| 9 | */ |
||
| 10 | protected $passKey = null; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var string |
||
| 14 | */ |
||
| 15 | protected $refNo = null; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $sentDate = null; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $idNo = null; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var string |
||
| 29 | */ |
||
| 30 | protected $cName = null; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | protected $cntry = null; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var string |
||
| 39 | */ |
||
| 40 | protected $cCity = null; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var string |
||
| 44 | */ |
||
| 45 | protected $cZip = null; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string |
||
| 49 | */ |
||
| 50 | protected $cPOBox = null; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string |
||
| 54 | */ |
||
| 55 | protected $cMobile = null; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var string |
||
| 59 | */ |
||
| 60 | protected $cTel1 = null; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var string |
||
| 64 | */ |
||
| 65 | protected $cTel2 = null; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var string |
||
| 69 | */ |
||
| 70 | protected $cAddr1 = null; |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @var string |
||
| 74 | */ |
||
| 75 | protected $cAddr2 = null; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * @var string |
||
| 79 | */ |
||
| 80 | protected $shipType = null; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @var int |
||
| 84 | */ |
||
| 85 | protected $PCs = null; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * @var string |
||
| 89 | */ |
||
| 90 | protected $cEmail = null; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var string |
||
| 94 | */ |
||
| 95 | protected $carrValue = null; |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @var string |
||
| 99 | */ |
||
| 100 | protected $carrCurr = null; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @var string |
||
| 104 | */ |
||
| 105 | protected $codAmt = null; |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @var string |
||
| 109 | */ |
||
| 110 | protected $weight = null; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @var string |
||
| 114 | */ |
||
| 115 | protected $custVal = null; |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @var string |
||
| 119 | */ |
||
| 120 | protected $custCurr = null; |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @var string |
||
| 124 | */ |
||
| 125 | protected $insrAmt = null; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @var string |
||
| 129 | */ |
||
| 130 | protected $insrCurr = null; |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @var string |
||
| 134 | */ |
||
| 135 | protected $itemDesc = null; |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @param string $passKey |
||
| 139 | * @param string $refNo |
||
| 140 | * @param string $sentDate |
||
| 141 | * @param string $idNo |
||
| 142 | * @param string $cName |
||
| 143 | * @param string $cntry |
||
| 144 | * @param string $cCity |
||
| 145 | * @param string $cZip |
||
| 146 | * @param string $cPOBox |
||
| 147 | * @param string $cMobile |
||
| 148 | * @param string $cTel1 |
||
| 149 | * @param string $cTel2 |
||
| 150 | * @param string $cAddr1 |
||
| 151 | * @param string $cAddr2 |
||
| 152 | * @param string $shipType |
||
| 153 | * @param int $PCs |
||
| 154 | * @param string $cEmail |
||
| 155 | * @param string $carrValue |
||
| 156 | * @param string $carrCurr |
||
| 157 | * @param string $codAmt |
||
| 158 | * @param string $weight |
||
| 159 | * @param string $custVal |
||
| 160 | * @param string $custCurr |
||
| 161 | * @param string $insrAmt |
||
| 162 | * @param string $insrCurr |
||
| 163 | * @param string $itemDesc |
||
| 164 | */ |
||
| 165 | public function __construct($passKey = null, $refNo = null, $sentDate = null, $idNo = null, $cName = null, $cntry = null, $cCity = null, $cZip = null, $cPOBox = null, $cMobile = null, $cTel1 = null, $cTel2 = null, $cAddr1 = null, $cAddr2 = null, $shipType = null, $PCs = null, $cEmail = null, $carrValue = null, $carrCurr = null, $codAmt = null, $weight = null, $custVal = null, $custCurr = null, $insrAmt = null, $insrCurr = null, $itemDesc = null) |
||
| 166 | { |
||
| 167 | $this->passKey = $passKey; |
||
| 168 | $this->refNo = $refNo; |
||
| 169 | $this->sentDate = $sentDate; |
||
| 170 | $this->idNo = $idNo; |
||
| 171 | $this->cName = $cName; |
||
| 172 | $this->cntry = $cntry; |
||
| 173 | $this->cCity = $cCity; |
||
| 174 | $this->cZip = $cZip; |
||
| 175 | $this->cPOBox = $cPOBox; |
||
| 176 | $this->cMobile = $cMobile; |
||
| 177 | $this->cTel1 = $cTel1; |
||
| 178 | $this->cTel2 = $cTel2; |
||
| 179 | $this->cAddr1 = $cAddr1; |
||
| 180 | $this->cAddr2 = $cAddr2; |
||
| 181 | $this->shipType = $shipType; |
||
| 182 | $this->PCs = $PCs; |
||
| 183 | $this->cEmail = $cEmail; |
||
| 184 | $this->carrValue = $carrValue; |
||
| 185 | $this->carrCurr = $carrCurr; |
||
| 186 | $this->codAmt = $codAmt; |
||
| 187 | $this->weight = $weight; |
||
| 188 | $this->custVal = $custVal; |
||
| 189 | $this->custCurr = $custCurr; |
||
| 190 | $this->insrAmt = $insrAmt; |
||
| 191 | $this->insrCurr = $insrCurr; |
||
| 192 | $this->itemDesc = $itemDesc; |
||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * @return string |
||
| 197 | */ |
||
| 198 | public function getPassKey() |
||
| 199 | { |
||
| 200 | return $this->passKey; |
||
| 201 | } |
||
| 202 | |||
| 203 | /** |
||
| 204 | * @param string $passKey |
||
| 205 | * |
||
| 206 | * @return \SmsaSDK\Methods\addShipment |
||
| 207 | */ |
||
| 208 | public function setPassKey($passKey) |
||
| 209 | { |
||
| 210 | $this->passKey = $passKey; |
||
| 211 | |||
| 212 | return $this; |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * @return string |
||
| 217 | */ |
||
| 218 | public function getRefNo() |
||
| 219 | { |
||
| 220 | return $this->refNo; |
||
| 221 | } |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @param string $refNo |
||
| 225 | * |
||
| 226 | * @return \SmsaSDK\Methods\addShipment |
||
| 227 | */ |
||
| 228 | public function setRefNo($refNo) |
||
| 229 | { |
||
| 230 | $this->refNo = $refNo; |
||
| 231 | |||
| 232 | return $this; |
||
| 233 | } |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @return string |
||
| 237 | */ |
||
| 238 | public function getSentDate() |
||
| 239 | { |
||
| 240 | return $this->sentDate; |
||
| 241 | } |
||
| 242 | |||
| 243 | /** |
||
| 244 | * @param string $sentDate |
||
| 245 | * |
||
| 246 | * @return \SmsaSDK\Methods\addShipment |
||
| 247 | */ |
||
| 248 | public function setSentDate($sentDate) |
||
| 249 | { |
||
| 250 | $this->sentDate = $sentDate; |
||
| 251 | |||
| 252 | return $this; |
||
| 253 | } |
||
| 254 | |||
| 255 | /** |
||
| 256 | * @return string |
||
| 257 | */ |
||
| 258 | public function getIdNo() |
||
| 259 | { |
||
| 260 | return $this->idNo; |
||
| 261 | } |
||
| 262 | |||
| 263 | /** |
||
| 264 | * @param string $idNo |
||
| 265 | * |
||
| 266 | * @return \SmsaSDK\Methods\addShipment |
||
| 267 | */ |
||
| 268 | public function setIdNo($idNo) |
||
| 269 | { |
||
| 270 | $this->idNo = $idNo; |
||
| 271 | |||
| 272 | return $this; |
||
| 273 | } |
||
| 274 | |||
| 275 | /** |
||
| 276 | * @return string |
||
| 277 | */ |
||
| 278 | public function getCName() |
||
| 279 | { |
||
| 280 | return $this->cName; |
||
| 281 | } |
||
| 282 | |||
| 283 | /** |
||
| 284 | * @param string $cName |
||
| 285 | * |
||
| 286 | * @return \SmsaSDK\Methods\addShipment |
||
| 287 | */ |
||
| 288 | public function setCName($cName) |
||
| 289 | { |
||
| 290 | $this->cName = $cName; |
||
| 291 | |||
| 292 | return $this; |
||
| 293 | } |
||
| 294 | |||
| 295 | /** |
||
| 296 | * @return string |
||
| 297 | */ |
||
| 298 | public function getCntry() |
||
| 299 | { |
||
| 300 | return $this->cntry; |
||
| 301 | } |
||
| 302 | |||
| 303 | /** |
||
| 304 | * @param string $cntry |
||
| 305 | * |
||
| 306 | * @return \SmsaSDK\Methods\addShipment |
||
| 307 | */ |
||
| 308 | public function setCntry($cntry) |
||
| 309 | { |
||
| 310 | $this->cntry = $cntry; |
||
| 311 | |||
| 312 | return $this; |
||
| 313 | } |
||
| 314 | |||
| 315 | /** |
||
| 316 | * @return string |
||
| 317 | */ |
||
| 318 | public function getCCity() |
||
| 319 | { |
||
| 320 | return $this->cCity; |
||
| 321 | } |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @param string $cCity |
||
| 325 | * |
||
| 326 | * @return \SmsaSDK\Methods\addShipment |
||
| 327 | */ |
||
| 328 | public function setCCity($cCity) |
||
| 329 | { |
||
| 330 | $this->cCity = $cCity; |
||
| 331 | |||
| 332 | return $this; |
||
| 333 | } |
||
| 334 | |||
| 335 | /** |
||
| 336 | * @return string |
||
| 337 | */ |
||
| 338 | public function getCZip() |
||
| 339 | { |
||
| 340 | return $this->cZip; |
||
| 341 | } |
||
| 342 | |||
| 343 | /** |
||
| 344 | * @param string $cZip |
||
| 345 | * |
||
| 346 | * @return \SmsaSDK\Methods\addShipment |
||
| 347 | */ |
||
| 348 | public function setCZip($cZip) |
||
| 349 | { |
||
| 350 | $this->cZip = $cZip; |
||
| 351 | |||
| 352 | return $this; |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @return string |
||
| 357 | */ |
||
| 358 | public function getCPOBox() |
||
| 359 | { |
||
| 360 | return $this->cPOBox; |
||
| 361 | } |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @param string $cPOBox |
||
| 365 | * |
||
| 366 | * @return \SmsaSDK\Methods\addShipment |
||
| 367 | */ |
||
| 368 | public function setCPOBox($cPOBox) |
||
| 369 | { |
||
| 370 | $this->cPOBox = $cPOBox; |
||
| 371 | |||
| 372 | return $this; |
||
| 373 | } |
||
| 374 | |||
| 375 | /** |
||
| 376 | * @return string |
||
| 377 | */ |
||
| 378 | public function getCMobile() |
||
| 379 | { |
||
| 380 | return $this->cMobile; |
||
| 381 | } |
||
| 382 | |||
| 383 | /** |
||
| 384 | * @param string $cMobile |
||
| 385 | * |
||
| 386 | * @return \SmsaSDK\Methods\addShipment |
||
| 387 | */ |
||
| 388 | public function setCMobile($cMobile) |
||
| 389 | { |
||
| 390 | $this->cMobile = $cMobile; |
||
| 391 | |||
| 392 | return $this; |
||
| 393 | } |
||
| 394 | |||
| 395 | /** |
||
| 396 | * @return string |
||
| 397 | */ |
||
| 398 | public function getCTel1() |
||
| 399 | { |
||
| 400 | return $this->cTel1; |
||
| 401 | } |
||
| 402 | |||
| 403 | /** |
||
| 404 | * @param string $cTel1 |
||
| 405 | * |
||
| 406 | * @return \SmsaSDK\Methods\addShipment |
||
| 407 | */ |
||
| 408 | public function setCTel1($cTel1) |
||
| 409 | { |
||
| 410 | $this->cTel1 = $cTel1; |
||
| 411 | |||
| 412 | return $this; |
||
| 413 | } |
||
| 414 | |||
| 415 | /** |
||
| 416 | * @return string |
||
| 417 | */ |
||
| 418 | public function getCTel2() |
||
| 419 | { |
||
| 420 | return $this->cTel2; |
||
| 421 | } |
||
| 422 | |||
| 423 | /** |
||
| 424 | * @param string $cTel2 |
||
| 425 | * |
||
| 426 | * @return \SmsaSDK\Methods\addShipment |
||
| 427 | */ |
||
| 428 | public function setCTel2($cTel2) |
||
| 429 | { |
||
| 430 | $this->cTel2 = $cTel2; |
||
| 431 | |||
| 432 | return $this; |
||
| 433 | } |
||
| 434 | |||
| 435 | /** |
||
| 436 | * @return string |
||
| 437 | */ |
||
| 438 | public function getCAddr1() |
||
| 439 | { |
||
| 440 | return $this->cAddr1; |
||
| 441 | } |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @param string $cAddr1 |
||
| 445 | * |
||
| 446 | * @return \SmsaSDK\Methods\addShipment |
||
| 447 | */ |
||
| 448 | public function setCAddr1($cAddr1) |
||
| 449 | { |
||
| 450 | $this->cAddr1 = $cAddr1; |
||
| 451 | |||
| 452 | return $this; |
||
| 453 | } |
||
| 454 | |||
| 455 | /** |
||
| 456 | * @return string |
||
| 457 | */ |
||
| 458 | public function getCAddr2() |
||
| 459 | { |
||
| 460 | return $this->cAddr2; |
||
| 461 | } |
||
| 462 | |||
| 463 | /** |
||
| 464 | * @param string $cAddr2 |
||
| 465 | * |
||
| 466 | * @return \SmsaSDK\Methods\addShipment |
||
| 467 | */ |
||
| 468 | public function setCAddr2($cAddr2) |
||
| 469 | { |
||
| 470 | $this->cAddr2 = $cAddr2; |
||
| 471 | |||
| 472 | return $this; |
||
| 473 | } |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @return string |
||
| 477 | */ |
||
| 478 | public function getShipType() |
||
| 479 | { |
||
| 480 | return $this->shipType; |
||
| 481 | } |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @param string $shipType |
||
| 485 | * |
||
| 486 | * @return \SmsaSDK\Methods\addShipment |
||
| 487 | */ |
||
| 488 | public function setShipType($shipType) |
||
| 489 | { |
||
| 490 | $this->shipType = $shipType; |
||
| 491 | |||
| 492 | return $this; |
||
| 493 | } |
||
| 494 | |||
| 495 | /** |
||
| 496 | * @return int |
||
| 497 | */ |
||
| 498 | public function getPCs() |
||
| 499 | { |
||
| 500 | return $this->PCs; |
||
| 501 | } |
||
| 502 | |||
| 503 | /** |
||
| 504 | * @param int $PCs |
||
| 505 | * |
||
| 506 | * @return \SmsaSDK\Methods\addShipment |
||
| 507 | */ |
||
| 508 | public function setPCs($PCs) |
||
| 509 | { |
||
| 510 | $this->PCs = $PCs; |
||
| 511 | |||
| 512 | return $this; |
||
| 513 | } |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @return string |
||
| 517 | */ |
||
| 518 | public function getCEmail() |
||
| 519 | { |
||
| 520 | return $this->cEmail; |
||
| 521 | } |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @param string $cEmail |
||
| 525 | * |
||
| 526 | * @return \SmsaSDK\Methods\addShipment |
||
| 527 | */ |
||
| 528 | public function setCEmail($cEmail) |
||
| 529 | { |
||
| 530 | $this->cEmail = $cEmail; |
||
| 531 | |||
| 532 | return $this; |
||
| 533 | } |
||
| 534 | |||
| 535 | /** |
||
| 536 | * @return string |
||
| 537 | */ |
||
| 538 | public function getCarrValue() |
||
| 539 | { |
||
| 540 | return $this->carrValue; |
||
| 541 | } |
||
| 542 | |||
| 543 | /** |
||
| 544 | * @param string $carrValue |
||
| 545 | * |
||
| 546 | * @return \SmsaSDK\Methods\addShipment |
||
| 547 | */ |
||
| 548 | public function setCarrValue($carrValue) |
||
| 549 | { |
||
| 550 | $this->carrValue = $carrValue; |
||
| 551 | |||
| 552 | return $this; |
||
| 553 | } |
||
| 554 | |||
| 555 | /** |
||
| 556 | * @return string |
||
| 557 | */ |
||
| 558 | public function getCarrCurr() |
||
| 559 | { |
||
| 560 | return $this->carrCurr; |
||
| 561 | } |
||
| 562 | |||
| 563 | /** |
||
| 564 | * @param string $carrCurr |
||
| 565 | * |
||
| 566 | * @return \SmsaSDK\Methods\addShipment |
||
| 567 | */ |
||
| 568 | public function setCarrCurr($carrCurr) |
||
| 569 | { |
||
| 570 | $this->carrCurr = $carrCurr; |
||
| 571 | |||
| 572 | return $this; |
||
| 573 | } |
||
| 574 | |||
| 575 | /** |
||
| 576 | * @return string |
||
| 577 | */ |
||
| 578 | public function getCodAmt() |
||
| 579 | { |
||
| 580 | return $this->codAmt; |
||
| 581 | } |
||
| 582 | |||
| 583 | /** |
||
| 584 | * @param string $codAmt |
||
| 585 | * |
||
| 586 | * @return \SmsaSDK\Methods\addShipment |
||
| 587 | */ |
||
| 588 | public function setCodAmt($codAmt) |
||
| 589 | { |
||
| 590 | $this->codAmt = $codAmt; |
||
| 591 | |||
| 592 | return $this; |
||
| 593 | } |
||
| 594 | |||
| 595 | /** |
||
| 596 | * @return string |
||
| 597 | */ |
||
| 598 | public function getWeight() |
||
| 599 | { |
||
| 600 | return $this->weight; |
||
| 601 | } |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @param string $weight |
||
| 605 | * |
||
| 606 | * @return \SmsaSDK\Methods\addShipment |
||
| 607 | */ |
||
| 608 | public function setWeight($weight) |
||
| 609 | { |
||
| 610 | $this->weight = $weight; |
||
| 611 | |||
| 612 | return $this; |
||
| 613 | } |
||
| 614 | |||
| 615 | /** |
||
| 616 | * @return string |
||
| 617 | */ |
||
| 618 | public function getCustVal() |
||
| 619 | { |
||
| 620 | return $this->custVal; |
||
| 621 | } |
||
| 622 | |||
| 623 | /** |
||
| 624 | * @param string $custVal |
||
| 625 | * |
||
| 626 | * @return \SmsaSDK\Methods\addShipment |
||
| 627 | */ |
||
| 628 | public function setCustVal($custVal) |
||
| 629 | { |
||
| 630 | $this->custVal = $custVal; |
||
| 631 | |||
| 632 | return $this; |
||
| 633 | } |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @return string |
||
| 637 | */ |
||
| 638 | public function getCustCurr() |
||
| 639 | { |
||
| 640 | return $this->custCurr; |
||
| 641 | } |
||
| 642 | |||
| 643 | /** |
||
| 644 | * @param string $custCurr |
||
| 645 | * |
||
| 646 | * @return \SmsaSDK\Methods\addShipment |
||
| 647 | */ |
||
| 648 | public function setCustCurr($custCurr) |
||
| 649 | { |
||
| 650 | $this->custCurr = $custCurr; |
||
| 651 | |||
| 652 | return $this; |
||
| 653 | } |
||
| 654 | |||
| 655 | /** |
||
| 656 | * @return string |
||
| 657 | */ |
||
| 658 | public function getInsrAmt() |
||
| 659 | { |
||
| 660 | return $this->insrAmt; |
||
| 661 | } |
||
| 662 | |||
| 663 | /** |
||
| 664 | * @param string $insrAmt |
||
| 665 | * |
||
| 666 | * @return \SmsaSDK\Methods\addShipment |
||
| 667 | */ |
||
| 668 | public function setInsrAmt($insrAmt) |
||
| 669 | { |
||
| 670 | $this->insrAmt = $insrAmt; |
||
| 671 | |||
| 672 | return $this; |
||
| 673 | } |
||
| 674 | |||
| 675 | /** |
||
| 676 | * @return string |
||
| 677 | */ |
||
| 678 | public function getInsrCurr() |
||
| 679 | { |
||
| 680 | return $this->insrCurr; |
||
| 681 | } |
||
| 682 | |||
| 683 | /** |
||
| 684 | * @param string $insrCurr |
||
| 685 | * |
||
| 686 | * @return \SmsaSDK\Methods\addShipment |
||
| 687 | */ |
||
| 688 | public function setInsrCurr($insrCurr) |
||
| 689 | { |
||
| 690 | $this->insrCurr = $insrCurr; |
||
| 691 | |||
| 692 | return $this; |
||
| 693 | } |
||
| 694 | |||
| 695 | /** |
||
| 696 | * @return string |
||
| 697 | */ |
||
| 698 | public function getItemDesc() |
||
| 699 | { |
||
| 700 | return $this->itemDesc; |
||
| 701 | } |
||
| 702 | |||
| 703 | /** |
||
| 704 | * @param string $itemDesc |
||
| 705 | * |
||
| 706 | * @return \SmsaSDK\Methods\addShipment |
||
| 707 | */ |
||
| 708 | public function setItemDesc($itemDesc) |
||
| 709 | { |
||
| 710 | $this->itemDesc = $itemDesc; |
||
| 711 | |||
| 712 | return $this; |
||
| 713 | } |
||
| 714 | } |
||
| 715 |