Complex classes like EntityBarcodeItem 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 EntityBarcodeItem, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | class EntityBarcodeItem implements EntityInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var int |
||
| 21 | */ |
||
| 22 | protected $anchorPoint; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var int |
||
| 26 | */ |
||
| 27 | protected $xPos; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var int |
||
| 31 | */ |
||
| 32 | protected $yPos; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var int |
||
| 36 | */ |
||
| 37 | protected $height; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var int |
||
| 41 | */ |
||
| 42 | protected $orion; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | protected $description; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var int |
||
| 51 | */ |
||
| 52 | protected $narrow; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var int |
||
| 56 | */ |
||
| 57 | protected $inverted; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var int |
||
| 61 | */ |
||
| 62 | protected $barcodeType; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var string |
||
| 66 | */ |
||
| 67 | protected $data; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var int |
||
| 71 | */ |
||
| 72 | protected $humanReadable; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var int |
||
| 76 | */ |
||
| 77 | protected $ratio; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var int |
||
| 81 | */ |
||
| 82 | protected $frame; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var int |
||
| 86 | */ |
||
| 87 | protected $showDropDowns; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var string |
||
| 91 | */ |
||
| 92 | protected $fontName; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var int |
||
| 96 | */ |
||
| 97 | protected $pointSize; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var int |
||
| 101 | */ |
||
| 102 | protected $bold; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var int |
||
| 106 | */ |
||
| 107 | protected $italic; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @var int |
||
| 111 | */ |
||
| 112 | protected $subType; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @var int |
||
| 116 | */ |
||
| 117 | protected $preferredFormat; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @var int |
||
| 121 | */ |
||
| 122 | protected $processTilde; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @var int |
||
| 126 | */ |
||
| 127 | protected $separatorHeight; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @var int |
||
| 131 | */ |
||
| 132 | protected $segmentWidth; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @var int |
||
| 136 | */ |
||
| 137 | protected $useHibc; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @var int |
||
| 141 | */ |
||
| 142 | protected $phantomField; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @return int |
||
| 146 | */ |
||
| 147 | 2 | public function getAnchorPoint() |
|
| 151 | |||
| 152 | /** |
||
| 153 | * @param int $anchorPoint |
||
| 154 | */ |
||
| 155 | public function setAnchorPoint($anchorPoint) |
||
| 159 | |||
| 160 | /** |
||
| 161 | * @return int |
||
| 162 | */ |
||
| 163 | 2 | public function getXPos() |
|
| 167 | |||
| 168 | /** |
||
| 169 | * @param int $xPos |
||
| 170 | */ |
||
| 171 | public function setXPos($xPos) |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @return int |
||
| 178 | */ |
||
| 179 | 2 | public function getYPos() |
|
| 183 | |||
| 184 | /** |
||
| 185 | * @param int $yPos |
||
| 186 | */ |
||
| 187 | public function setYPos($yPos) |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @return int |
||
| 194 | */ |
||
| 195 | 2 | public function getHeight() |
|
| 199 | |||
| 200 | /** |
||
| 201 | * @param int $height |
||
| 202 | */ |
||
| 203 | public function setHeight($height) |
||
| 207 | |||
| 208 | /** |
||
| 209 | * @return int |
||
| 210 | */ |
||
| 211 | 2 | public function getOrion() |
|
| 215 | |||
| 216 | /** |
||
| 217 | * @param int $orion |
||
| 218 | */ |
||
| 219 | public function setOrion($orion) |
||
| 223 | |||
| 224 | /** |
||
| 225 | * @return string |
||
| 226 | */ |
||
| 227 | 2 | public function getDescription() |
|
| 231 | |||
| 232 | /** |
||
| 233 | * @param string $description |
||
| 234 | */ |
||
| 235 | public function setDescription($description) |
||
| 239 | |||
| 240 | /** |
||
| 241 | * @return int |
||
| 242 | */ |
||
| 243 | 2 | public function getNarrow() |
|
| 247 | |||
| 248 | /** |
||
| 249 | * @param int $narrow |
||
| 250 | */ |
||
| 251 | public function setNarrow($narrow) |
||
| 255 | |||
| 256 | /** |
||
| 257 | * @return int |
||
| 258 | */ |
||
| 259 | 2 | public function getInverted() |
|
| 263 | |||
| 264 | /** |
||
| 265 | * @param int $inverted |
||
| 266 | */ |
||
| 267 | public function setInverted($inverted) |
||
| 271 | |||
| 272 | /** |
||
| 273 | * @return int |
||
| 274 | */ |
||
| 275 | 2 | public function getBarcodeType() |
|
| 279 | |||
| 280 | /** |
||
| 281 | * @param int $barcodeType |
||
| 282 | */ |
||
| 283 | public function setBarcodeType($barcodeType) |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @return string |
||
| 290 | */ |
||
| 291 | 2 | public function getData() |
|
| 295 | |||
| 296 | /** |
||
| 297 | * @param string $data |
||
| 298 | */ |
||
| 299 | public function setData($data) |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @return int |
||
| 306 | */ |
||
| 307 | 2 | public function getHumanReadable() |
|
| 311 | |||
| 312 | /** |
||
| 313 | * @param int $humanReadable |
||
| 314 | */ |
||
| 315 | public function setHumanReadable($humanReadable) |
||
| 319 | |||
| 320 | /** |
||
| 321 | * @return int |
||
| 322 | */ |
||
| 323 | 2 | public function getRatio() |
|
| 327 | |||
| 328 | /** |
||
| 329 | * @param int $ratio |
||
| 330 | */ |
||
| 331 | public function setRatio($ratio) |
||
| 335 | |||
| 336 | /** |
||
| 337 | * @return int |
||
| 338 | */ |
||
| 339 | 2 | public function getFrame() |
|
| 343 | |||
| 344 | /** |
||
| 345 | * @param int $frame |
||
| 346 | */ |
||
| 347 | public function setFrame($frame) |
||
| 351 | |||
| 352 | /** |
||
| 353 | * @return int |
||
| 354 | */ |
||
| 355 | 2 | public function getShowDropDowns() |
|
| 359 | |||
| 360 | /** |
||
| 361 | * @param int $showDropDowns |
||
| 362 | */ |
||
| 363 | public function setShowDropDowns($showDropDowns) |
||
| 367 | |||
| 368 | /** |
||
| 369 | * @return string |
||
| 370 | */ |
||
| 371 | 2 | public function getFontName() |
|
| 375 | |||
| 376 | /** |
||
| 377 | * @param string $fontName |
||
| 378 | */ |
||
| 379 | public function setFontName($fontName) |
||
| 383 | |||
| 384 | /** |
||
| 385 | * @return int |
||
| 386 | */ |
||
| 387 | 2 | public function getPointSize() |
|
| 391 | |||
| 392 | /** |
||
| 393 | * @param int $pointSize |
||
| 394 | */ |
||
| 395 | public function setPointSize($pointSize) |
||
| 399 | |||
| 400 | /** |
||
| 401 | * @return int |
||
| 402 | */ |
||
| 403 | 2 | public function getBold() |
|
| 407 | |||
| 408 | /** |
||
| 409 | * @param int $bold |
||
| 410 | */ |
||
| 411 | public function setBold($bold) |
||
| 415 | |||
| 416 | /** |
||
| 417 | * @return int |
||
| 418 | */ |
||
| 419 | 2 | public function getItalic() |
|
| 423 | |||
| 424 | /** |
||
| 425 | * @param int $italic |
||
| 426 | */ |
||
| 427 | public function setItalic($italic) |
||
| 431 | |||
| 432 | /** |
||
| 433 | * @return int |
||
| 434 | */ |
||
| 435 | 2 | public function getSubType() |
|
| 439 | |||
| 440 | /** |
||
| 441 | * @param int $subType |
||
| 442 | */ |
||
| 443 | public function setSubType($subType) |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @return int |
||
| 450 | */ |
||
| 451 | 2 | public function getPreferredFormat() |
|
| 455 | |||
| 456 | /** |
||
| 457 | * @param int $preferredFormat |
||
| 458 | */ |
||
| 459 | public function setPreferredFormat($preferredFormat) |
||
| 463 | |||
| 464 | /** |
||
| 465 | * @return int |
||
| 466 | */ |
||
| 467 | 2 | public function getProcessTilde() |
|
| 471 | |||
| 472 | /** |
||
| 473 | * @param int $processTilde |
||
| 474 | */ |
||
| 475 | public function setProcessTilde($processTilde) |
||
| 479 | |||
| 480 | /** |
||
| 481 | * @return int |
||
| 482 | */ |
||
| 483 | 2 | public function getSeparatorHeight() |
|
| 487 | |||
| 488 | /** |
||
| 489 | * @param int $separatorHeight |
||
| 490 | */ |
||
| 491 | public function setSeparatorHeight($separatorHeight) |
||
| 495 | |||
| 496 | /** |
||
| 497 | * @return int |
||
| 498 | */ |
||
| 499 | 2 | public function getSegmentWidth() |
|
| 503 | |||
| 504 | /** |
||
| 505 | * @param int $segmentWidth |
||
| 506 | */ |
||
| 507 | public function setSegmentWidth($segmentWidth) |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @return int |
||
| 514 | */ |
||
| 515 | 2 | public function getUseHibc() |
|
| 519 | |||
| 520 | /** |
||
| 521 | * @param int $useHibc |
||
| 522 | */ |
||
| 523 | public function setUseHibc($useHibc) |
||
| 527 | |||
| 528 | /** |
||
| 529 | * @return int |
||
| 530 | */ |
||
| 531 | 2 | public function getPhantomField() |
|
| 535 | |||
| 536 | /** |
||
| 537 | * @param int $phantomField |
||
| 538 | */ |
||
| 539 | public function setPhantomField($phantomField) |
||
| 543 | } |
||
| 544 |