Complex classes like WebHostReportEntryItem 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 WebHostReportEntryItem, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 7 | class WebHostReportEntryItem |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var int |
||
| 12 | */ |
||
| 13 | protected $rowNumber; |
||
| 14 | |||
| 15 | |||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | protected $type; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $domain; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var string |
||
| 28 | */ |
||
| 29 | protected $additionalDomain; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | protected $mdcDomainNames; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var string |
||
| 38 | */ |
||
| 39 | protected $status; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var \DateTime |
||
| 43 | */ |
||
| 44 | protected $lastStatusChange; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var \DateTime |
||
| 48 | */ |
||
| 49 | protected $notBefore; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var \DateTime |
||
| 53 | */ |
||
| 54 | protected $notAfter; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @var string |
||
| 58 | */ |
||
| 59 | protected $serialNumber; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @var string |
||
| 63 | */ |
||
| 64 | protected $signatureAlgorithm; |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @var string |
||
| 68 | */ |
||
| 69 | protected $keySize; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @var string |
||
| 73 | */ |
||
| 74 | protected $webServerSoftware; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @var string |
||
| 78 | */ |
||
| 79 | protected $certificateID; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @var string |
||
| 83 | */ |
||
| 84 | protected $csrStatus; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @var string |
||
| 88 | */ |
||
| 89 | protected $dcvStatus; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @var string |
||
| 93 | */ |
||
| 94 | protected $ovCallBackStatus; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var string |
||
| 98 | */ |
||
| 99 | protected $organizationValidationStatus; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * @var string |
||
| 103 | */ |
||
| 104 | protected $countryName; |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @var string |
||
| 108 | */ |
||
| 109 | protected $freeDVUPStatus; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * @var string |
||
| 113 | */ |
||
| 114 | protected $evClickThroughStatus; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @return int |
||
| 118 | */ |
||
| 119 | public function getRowNumber() |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @param int $rowNumber |
||
| 126 | * @return WebHostReportEntry |
||
| 127 | */ |
||
| 128 | public function setRowNumber($rowNumber) |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @return string |
||
| 136 | */ |
||
| 137 | public function getType() |
||
| 141 | |||
| 142 | /** |
||
| 143 | * @param string $type |
||
| 144 | * @return WebHostReportEntry |
||
| 145 | */ |
||
| 146 | public function setType($type) |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @return string |
||
| 154 | */ |
||
| 155 | public function getDomain() |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @param string $domain |
||
| 162 | * @return WebHostReportEntry |
||
| 163 | */ |
||
| 164 | public function setDomain($domain) |
||
| 169 | |||
| 170 | /** |
||
| 171 | * @return string |
||
| 172 | */ |
||
| 173 | public function getAdditionalDomain() |
||
| 177 | |||
| 178 | /** |
||
| 179 | * @param string $additionalDomain |
||
| 180 | * @return WebHostReportEntry |
||
| 181 | */ |
||
| 182 | public function setAdditionalDomain($additionalDomain) |
||
| 187 | |||
| 188 | /** |
||
| 189 | * @return string |
||
| 190 | */ |
||
| 191 | public function getMdcDomainNames() |
||
| 195 | |||
| 196 | /** |
||
| 197 | * @param string $mdcDomainNames |
||
| 198 | * @return WebHostReportEntry |
||
| 199 | */ |
||
| 200 | public function setMdcDomainNames($mdcDomainNames) |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @return string |
||
| 208 | */ |
||
| 209 | public function getStatus() |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @param string $status |
||
| 216 | * @return WebHostReportEntry |
||
| 217 | */ |
||
| 218 | public function setStatus($status) |
||
| 223 | |||
| 224 | /** |
||
| 225 | * @return \DateTime |
||
| 226 | */ |
||
| 227 | public function getLastStatusChange() |
||
| 231 | |||
| 232 | /** |
||
| 233 | * @param \DateTime $lastStatusChange |
||
| 234 | * @return WebHostReportEntry |
||
| 235 | */ |
||
| 236 | public function setLastStatusChange($lastStatusChange) |
||
| 245 | |||
| 246 | /** |
||
| 247 | * @return \DateTime |
||
| 248 | */ |
||
| 249 | public function getNotBefore() |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @param \DateTime $notBefore |
||
| 256 | * @return WebHostReportEntry |
||
| 257 | */ |
||
| 258 | public function setNotBefore($notBefore) |
||
| 267 | |||
| 268 | /** |
||
| 269 | * @return \DateTime |
||
| 270 | */ |
||
| 271 | public function getNotAfter() |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @param \DateTime $notAfter |
||
| 278 | * @return WebHostReportEntry |
||
| 279 | */ |
||
| 280 | public function setNotAfter($notAfter) |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @return string |
||
| 292 | */ |
||
| 293 | public function getSerialNumber() |
||
| 297 | |||
| 298 | /** |
||
| 299 | * @param string $serialNumber |
||
| 300 | * @return WebHostReportEntry |
||
| 301 | */ |
||
| 302 | public function setSerialNumber($serialNumber) |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @return string |
||
| 310 | */ |
||
| 311 | public function getSignatureAlgorithm() |
||
| 315 | |||
| 316 | /** |
||
| 317 | * @param string $signatureAlgorithm |
||
| 318 | * @return WebHostReportEntry |
||
| 319 | */ |
||
| 320 | public function setSignatureAlgorithm($signatureAlgorithm) |
||
| 325 | |||
| 326 | /** |
||
| 327 | * @return string |
||
| 328 | */ |
||
| 329 | public function getKeySize() |
||
| 333 | |||
| 334 | /** |
||
| 335 | * @param string $keySize |
||
| 336 | * @return WebHostReportEntry |
||
| 337 | */ |
||
| 338 | public function setKeySize($keySize) |
||
| 343 | |||
| 344 | /** |
||
| 345 | * @return string |
||
| 346 | */ |
||
| 347 | public function getWebServerSoftware() |
||
| 351 | |||
| 352 | /** |
||
| 353 | * @param string $webServerSoftware |
||
| 354 | * @return WebHostReportEntry |
||
| 355 | */ |
||
| 356 | public function setWebServerSoftware($webServerSoftware) |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @return string |
||
| 364 | */ |
||
| 365 | public function getCertificateID() |
||
| 369 | |||
| 370 | /** |
||
| 371 | * @param string $certificateID |
||
| 372 | * @return WebHostReportEntry |
||
| 373 | */ |
||
| 374 | public function setCertificateID($certificateID) |
||
| 379 | |||
| 380 | /** |
||
| 381 | * @return string |
||
| 382 | */ |
||
| 383 | public function getCsrStatus() |
||
| 387 | |||
| 388 | /** |
||
| 389 | * @param string $csrStatus |
||
| 390 | * @return WebHostReportEntry |
||
| 391 | */ |
||
| 392 | public function setCsrStatus($csrStatus) |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @return string |
||
| 400 | */ |
||
| 401 | public function getDcvStatus() |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @param string $dcvStatus |
||
| 408 | * @return WebHostReportEntry |
||
| 409 | */ |
||
| 410 | public function setDcvStatus($dcvStatus) |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @return string |
||
| 418 | */ |
||
| 419 | public function getOvCallBackStatus() |
||
| 423 | |||
| 424 | /** |
||
| 425 | * @param string $ovCallBackStatus |
||
| 426 | * @return WebHostReportEntry |
||
| 427 | */ |
||
| 428 | public function setOvCallBackStatus($ovCallBackStatus) |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @return string |
||
| 436 | */ |
||
| 437 | public function getOrganizationValidationStatus() |
||
| 441 | |||
| 442 | /** |
||
| 443 | * @param string $organizationValidationStatus |
||
| 444 | * @return WebHostReportEntry |
||
| 445 | */ |
||
| 446 | public function setOrganizationValidationStatus($organizationValidationStatus) |
||
| 451 | |||
| 452 | /** |
||
| 453 | * @return string |
||
| 454 | */ |
||
| 455 | public function getCountryName() |
||
| 459 | |||
| 460 | /** |
||
| 461 | * @param string $countryName |
||
| 462 | * @return WebHostReportEntry |
||
| 463 | */ |
||
| 464 | public function setCountryName($countryName) |
||
| 469 | |||
| 470 | /** |
||
| 471 | * @return string |
||
| 472 | */ |
||
| 473 | public function getFreeDVUPStatus() |
||
| 477 | |||
| 478 | /** |
||
| 479 | * @param string $freeDVUPStatus |
||
| 480 | * @return WebHostReportEntry |
||
| 481 | */ |
||
| 482 | public function setFreeDVUPStatus($freeDVUPStatus) |
||
| 487 | |||
| 488 | /** |
||
| 489 | * @return string |
||
| 490 | */ |
||
| 491 | public function getEvClickThroughStatus() |
||
| 495 | |||
| 496 | /** |
||
| 497 | * @param string $evClickThroughStatus |
||
| 498 | * @return WebHostReportEntry |
||
| 499 | */ |
||
| 500 | public function setEvClickThroughStatus($evClickThroughStatus) |
||
| 505 | |||
| 506 | |||
| 507 | |||
| 508 | } |
||
| 509 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.