Complex classes like EntityVarDatabase 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 EntityVarDatabase, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | class EntityVarDatabase implements EntityInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | protected $name; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $dataSource; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | protected $refFileName; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | protected $table; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | protected $keyField; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | protected $dataField; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | protected $prompt; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var int |
||
| 56 | */ |
||
| 57 | protected $displayLength; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var int |
||
| 61 | */ |
||
| 62 | protected $trimTrailingSpaces; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var int |
||
| 66 | */ |
||
| 67 | protected $printAll; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var int |
||
| 71 | */ |
||
| 72 | protected $fixedKey; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var int |
||
| 76 | */ |
||
| 77 | protected $singleData; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var int |
||
| 81 | */ |
||
| 82 | protected $usePrompt; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var string |
||
| 86 | */ |
||
| 87 | protected $keyData; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var string |
||
| 91 | */ |
||
| 92 | protected $fixedKeyData; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var string |
||
| 96 | */ |
||
| 97 | protected $codePage; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var int |
||
| 101 | */ |
||
| 102 | protected $numberOfDecimals; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var int |
||
| 106 | */ |
||
| 107 | protected $runSequence; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @var int |
||
| 111 | */ |
||
| 112 | protected $actionWhenDone; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @var int |
||
| 116 | */ |
||
| 117 | protected $rawBaseData; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @var int |
||
| 121 | */ |
||
| 122 | protected $databaseType; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @var int |
||
| 126 | */ |
||
| 127 | protected $cPadding; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @return string |
||
| 131 | */ |
||
| 132 | 1 | public function getName() |
|
| 136 | |||
| 137 | /** |
||
| 138 | * @param string $name |
||
| 139 | */ |
||
| 140 | public function setName($name) |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @return string |
||
| 147 | */ |
||
| 148 | 1 | public function getDataSource() |
|
| 152 | |||
| 153 | /** |
||
| 154 | * @param string $dataSource |
||
| 155 | */ |
||
| 156 | public function setDataSource($dataSource) |
||
| 160 | |||
| 161 | /** |
||
| 162 | * @return string |
||
| 163 | */ |
||
| 164 | 1 | public function getRefFileName() |
|
| 168 | |||
| 169 | /** |
||
| 170 | * @param string $refFileName |
||
| 171 | */ |
||
| 172 | public function setRefFileName($refFileName) |
||
| 176 | |||
| 177 | /** |
||
| 178 | * @return string |
||
| 179 | */ |
||
| 180 | 1 | public function getTable() |
|
| 184 | |||
| 185 | /** |
||
| 186 | * @param string $table |
||
| 187 | */ |
||
| 188 | public function setTable($table) |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @return string |
||
| 195 | */ |
||
| 196 | 1 | public function getKeyField() |
|
| 200 | |||
| 201 | /** |
||
| 202 | * @param string $keyField |
||
| 203 | */ |
||
| 204 | public function setKeyField($keyField) |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @return string |
||
| 211 | */ |
||
| 212 | 1 | public function getDataField() |
|
| 216 | |||
| 217 | /** |
||
| 218 | * @param string $dataField |
||
| 219 | */ |
||
| 220 | public function setDataField($dataField) |
||
| 224 | |||
| 225 | /** |
||
| 226 | * @return string |
||
| 227 | */ |
||
| 228 | 1 | public function getPrompt() |
|
| 232 | |||
| 233 | /** |
||
| 234 | * @param string $prompt |
||
| 235 | */ |
||
| 236 | public function setPrompt($prompt) |
||
| 240 | |||
| 241 | /** |
||
| 242 | * @return int |
||
| 243 | */ |
||
| 244 | 1 | public function getDisplayLength() |
|
| 248 | |||
| 249 | /** |
||
| 250 | * @param int $displayLength |
||
| 251 | */ |
||
| 252 | public function setDisplayLength($displayLength) |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @return int |
||
| 259 | */ |
||
| 260 | 1 | public function getTrimTrailingSpaces() |
|
| 264 | |||
| 265 | /** |
||
| 266 | * @param int $trimTrailingSpaces |
||
| 267 | */ |
||
| 268 | public function setTrimTrailingSpaces($trimTrailingSpaces) |
||
| 272 | |||
| 273 | /** |
||
| 274 | * @return int |
||
| 275 | */ |
||
| 276 | 1 | public function getPrintAll() |
|
| 280 | |||
| 281 | /** |
||
| 282 | * @param int $printAll |
||
| 283 | */ |
||
| 284 | public function setPrintAll($printAll) |
||
| 288 | |||
| 289 | /** |
||
| 290 | * @return int |
||
| 291 | */ |
||
| 292 | 1 | public function getFixedKey() |
|
| 296 | |||
| 297 | /** |
||
| 298 | * @param int $fixedKey |
||
| 299 | */ |
||
| 300 | public function setFixedKey($fixedKey) |
||
| 304 | |||
| 305 | /** |
||
| 306 | * @return int |
||
| 307 | */ |
||
| 308 | 1 | public function getSingleData() |
|
| 312 | |||
| 313 | /** |
||
| 314 | * @param int $singleData |
||
| 315 | */ |
||
| 316 | public function setSingleData($singleData) |
||
| 320 | |||
| 321 | /** |
||
| 322 | * @return int |
||
| 323 | */ |
||
| 324 | 1 | public function getUsePrompt() |
|
| 328 | |||
| 329 | /** |
||
| 330 | * @param int $usePrompt |
||
| 331 | */ |
||
| 332 | public function setUsePrompt($usePrompt) |
||
| 336 | |||
| 337 | /** |
||
| 338 | * @return string |
||
| 339 | */ |
||
| 340 | 1 | public function getKeyData() |
|
| 344 | |||
| 345 | /** |
||
| 346 | * @param string $keyData |
||
| 347 | */ |
||
| 348 | public function setKeyData($keyData) |
||
| 352 | |||
| 353 | /** |
||
| 354 | * @return string |
||
| 355 | */ |
||
| 356 | 1 | public function getFixedKeyData() |
|
| 360 | |||
| 361 | /** |
||
| 362 | * @param string $fixedKeyData |
||
| 363 | */ |
||
| 364 | public function setFixedKeyData($fixedKeyData) |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @return string |
||
| 371 | */ |
||
| 372 | 1 | public function getCodePage() |
|
| 376 | |||
| 377 | /** |
||
| 378 | * @param string $codePage |
||
| 379 | */ |
||
| 380 | public function setCodePage($codePage) |
||
| 384 | |||
| 385 | /** |
||
| 386 | * @return int |
||
| 387 | */ |
||
| 388 | 1 | public function getNumberOfDecimals() |
|
| 392 | |||
| 393 | /** |
||
| 394 | * @param int $numberOfDecimals |
||
| 395 | */ |
||
| 396 | public function setNumberOfDecimals($numberOfDecimals) |
||
| 400 | |||
| 401 | /** |
||
| 402 | * @return int |
||
| 403 | */ |
||
| 404 | 1 | public function getRunSequence() |
|
| 408 | |||
| 409 | /** |
||
| 410 | * @param int $runSequence |
||
| 411 | */ |
||
| 412 | public function setRunSequence($runSequence) |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @return int |
||
| 419 | */ |
||
| 420 | 1 | public function getActionWhenDone() |
|
| 424 | |||
| 425 | /** |
||
| 426 | * @param int $actionWhenDone |
||
| 427 | */ |
||
| 428 | public function setActionWhenDone($actionWhenDone) |
||
| 432 | |||
| 433 | /** |
||
| 434 | * @return int |
||
| 435 | */ |
||
| 436 | 1 | public function getrawBaseData() |
|
| 440 | |||
| 441 | /** |
||
| 442 | * @param int $rawBaseData |
||
| 443 | */ |
||
| 444 | public function setrawBaseData($rawBaseData) |
||
| 448 | |||
| 449 | /** |
||
| 450 | * @return int |
||
| 451 | */ |
||
| 452 | 1 | public function getDatabaseType() |
|
| 456 | |||
| 457 | /** |
||
| 458 | * @param int $databaseType |
||
| 459 | */ |
||
| 460 | public function setDatabaseType($databaseType) |
||
| 464 | |||
| 465 | /** |
||
| 466 | * @return int |
||
| 467 | */ |
||
| 468 | 1 | public function getcPadding() |
|
| 472 | |||
| 473 | /** |
||
| 474 | * @param int $cPadding |
||
| 475 | */ |
||
| 476 | public function setcPadding($cPadding) |
||
| 480 | } |
||
| 481 |