| Total Complexity | 58 |
| Total Lines | 542 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like ColumnModel 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.
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 ColumnModel, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 12 | class ColumnModel |
||
| 13 | { |
||
| 14 | |||
| 15 | private $label; |
||
| 16 | private $name; |
||
| 17 | private $field; |
||
| 18 | private $type; |
||
| 19 | private $show_detail; |
||
| 20 | private $show_index; |
||
| 21 | private $show_edit; |
||
| 22 | private $show_add; |
||
| 23 | private $visible; |
||
| 24 | private $input_width; |
||
| 25 | private $column_width; |
||
| 26 | private $required; |
||
| 27 | private $readonly; |
||
| 28 | private $disabled; |
||
| 29 | private $help; |
||
| 30 | private $placeholder; |
||
| 31 | private $validation; |
||
| 32 | private $validation_messages; |
||
| 33 | private $value; |
||
| 34 | private $default_value; |
||
| 35 | private $style; |
||
| 36 | private $onchange_js_function_name; |
||
| 37 | private $onchange_js_function_callback; |
||
| 38 | |||
| 39 | private $onclick_js_function_name; |
||
| 40 | private $onclick_js_function_callback; |
||
| 41 | |||
| 42 | private $onblur_js_function_name; |
||
| 43 | private $onblur_js_function_callback; |
||
| 44 | |||
| 45 | private $index_display_transform; |
||
| 46 | private $detail_display_transform; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return mixed |
||
| 50 | */ |
||
| 51 | public function getOnclickJsFunctionName() |
||
| 52 | { |
||
| 53 | return $this->onclick_js_function_name; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param mixed $onclick_js_function_name |
||
| 58 | */ |
||
| 59 | public function setOnclickJsFunctionName($onclick_js_function_name): void |
||
| 60 | { |
||
| 61 | $this->onclick_js_function_name = $onclick_js_function_name; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return mixed |
||
| 66 | */ |
||
| 67 | public function getOnclickJsFunctionCallback() |
||
| 68 | { |
||
| 69 | return $this->onclick_js_function_callback; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param mixed $onclick_js_function_callback |
||
| 74 | */ |
||
| 75 | public function setOnclickJsFunctionCallback($onclick_js_function_callback): void |
||
| 76 | { |
||
| 77 | $this->onclick_js_function_callback = $onclick_js_function_callback; |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return mixed |
||
| 82 | */ |
||
| 83 | public function getOnblurJsFunctionName() |
||
| 84 | { |
||
| 85 | return $this->onblur_js_function_name; |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param mixed $onblur_js_function_name |
||
| 90 | */ |
||
| 91 | public function setOnblurJsFunctionName($onblur_js_function_name): void |
||
| 92 | { |
||
| 93 | $this->onblur_js_function_name = $onblur_js_function_name; |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @return mixed |
||
| 98 | */ |
||
| 99 | public function getOnblurJsFunctionCallback() |
||
| 100 | { |
||
| 101 | return $this->onblur_js_function_callback; |
||
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @param mixed $onblur_js_function_callback |
||
| 106 | */ |
||
| 107 | public function setOnblurJsFunctionCallback($onblur_js_function_callback): void |
||
| 108 | { |
||
| 109 | $this->onblur_js_function_callback = $onblur_js_function_callback; |
||
| 110 | } |
||
| 111 | |||
| 112 | |||
| 113 | |||
| 114 | /** |
||
| 115 | * @return mixed |
||
| 116 | */ |
||
| 117 | public function getOnchangeJsFunctionName() |
||
| 118 | { |
||
| 119 | return $this->onchange_js_function_name; |
||
| 120 | } |
||
| 121 | |||
| 122 | /** |
||
| 123 | * @param mixed $onchange_js_function_name |
||
| 124 | */ |
||
| 125 | public function setOnchangeJsFunctionName($onchange_js_function_name): void |
||
| 126 | { |
||
| 127 | $this->onchange_js_function_name = $onchange_js_function_name; |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @return mixed |
||
| 132 | */ |
||
| 133 | public function getOnchangeJsFunctionCallback() |
||
| 134 | { |
||
| 135 | return $this->onchange_js_function_callback; |
||
| 136 | } |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @param mixed $onchange_js_function_callback |
||
| 140 | */ |
||
| 141 | public function setOnchangeJsFunctionCallback($onchange_js_function_callback): void |
||
| 142 | { |
||
| 143 | $this->onchange_js_function_callback = $onchange_js_function_callback; |
||
| 144 | } |
||
| 145 | |||
| 146 | |||
| 147 | |||
| 148 | /** |
||
| 149 | * @return mixed |
||
| 150 | */ |
||
| 151 | public function getIndexDisplayTransform() |
||
| 152 | { |
||
| 153 | return $this->index_display_transform; |
||
| 154 | } |
||
| 155 | |||
| 156 | /** |
||
| 157 | * @param mixed $index_display_transform |
||
| 158 | */ |
||
| 159 | public function setIndexDisplayTransform($index_display_transform) |
||
| 160 | { |
||
| 161 | $this->index_display_transform = $index_display_transform; |
||
| 162 | } |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @return mixed |
||
| 166 | */ |
||
| 167 | public function getDetailDisplayTransform() |
||
| 168 | { |
||
| 169 | return $this->detail_display_transform; |
||
| 170 | } |
||
| 171 | |||
| 172 | /** |
||
| 173 | * @param mixed $detail_display_transform |
||
| 174 | */ |
||
| 175 | public function setDetailDisplayTransform($detail_display_transform) |
||
| 176 | { |
||
| 177 | $this->detail_display_transform = $detail_display_transform; |
||
| 178 | } |
||
| 179 | |||
| 180 | |||
| 181 | |||
| 182 | /** |
||
| 183 | * @return mixed |
||
| 184 | */ |
||
| 185 | public function getDefaultValue() |
||
| 186 | { |
||
| 187 | return $this->default_value; |
||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @param mixed $default_value |
||
| 192 | */ |
||
| 193 | public function setDefaultValue($default_value): void |
||
| 194 | { |
||
| 195 | $this->default_value = $default_value; |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * @return mixed |
||
| 200 | */ |
||
| 201 | public function getDisabled() |
||
| 202 | { |
||
| 203 | return $this->disabled; |
||
| 204 | } |
||
| 205 | |||
| 206 | /** |
||
| 207 | * @param mixed $disabled |
||
| 208 | */ |
||
| 209 | public function setDisabled($disabled): void |
||
| 210 | { |
||
| 211 | $this->disabled = $disabled; |
||
| 212 | } |
||
| 213 | |||
| 214 | |||
| 215 | /** |
||
| 216 | * @return mixed |
||
| 217 | */ |
||
| 218 | public function getReadonly() |
||
| 219 | { |
||
| 220 | return $this->readonly; |
||
| 221 | } |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @param mixed $readonly |
||
| 225 | */ |
||
| 226 | public function setReadonly($readonly): void |
||
| 227 | { |
||
| 228 | $this->readonly = $readonly; |
||
| 229 | } |
||
| 230 | |||
| 231 | |||
| 232 | /** |
||
| 233 | * @return mixed |
||
| 234 | */ |
||
| 235 | public function getStyle() |
||
| 236 | { |
||
| 237 | return $this->style; |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * @param mixed $style |
||
| 242 | */ |
||
| 243 | public function setStyle($style): void |
||
| 244 | { |
||
| 245 | $this->style = $style; |
||
| 246 | } |
||
| 247 | |||
| 248 | |||
| 249 | /** |
||
| 250 | * @return mixed |
||
| 251 | */ |
||
| 252 | public function getValue() |
||
| 253 | { |
||
| 254 | return $this->value; |
||
| 255 | } |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @param mixed $value |
||
| 259 | * @return ColumnModel |
||
| 260 | */ |
||
| 261 | public function setValue($value) |
||
| 262 | { |
||
| 263 | $this->value = $value; |
||
| 264 | return $this; |
||
| 265 | } |
||
| 266 | |||
| 267 | |||
| 268 | /** |
||
| 269 | * @return mixed |
||
| 270 | */ |
||
| 271 | public function getLabel() |
||
| 272 | { |
||
| 273 | return $this->label; |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @param mixed $label |
||
| 278 | * @return ColumnModel |
||
| 279 | */ |
||
| 280 | public function setLabel($label) |
||
| 281 | { |
||
| 282 | $this->label = $label; |
||
| 283 | return $this; |
||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @return mixed |
||
| 288 | */ |
||
| 289 | public function getName() |
||
| 290 | { |
||
| 291 | return $this->name; |
||
| 292 | } |
||
| 293 | |||
| 294 | /** |
||
| 295 | * @param mixed $name |
||
| 296 | * @return ColumnModel |
||
| 297 | */ |
||
| 298 | public function setName($name) |
||
| 299 | { |
||
| 300 | $this->name = $name; |
||
| 301 | return $this; |
||
| 302 | } |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @return mixed |
||
| 306 | */ |
||
| 307 | public function getField() |
||
| 308 | { |
||
| 309 | return $this->field; |
||
| 310 | } |
||
| 311 | |||
| 312 | /** |
||
| 313 | * @param mixed $field |
||
| 314 | * @return ColumnModel |
||
| 315 | */ |
||
| 316 | public function setField($field) |
||
| 320 | } |
||
| 321 | |||
| 322 | /** |
||
| 323 | * @return mixed |
||
| 324 | */ |
||
| 325 | public function getType() |
||
| 326 | { |
||
| 327 | return $this->type; |
||
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * @param mixed $type |
||
| 332 | * @return ColumnModel |
||
| 333 | */ |
||
| 334 | public function setType($type) |
||
| 335 | { |
||
| 336 | $this->type = $type; |
||
| 337 | return $this; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @return mixed |
||
| 342 | */ |
||
| 343 | public function getShowDetail() |
||
| 344 | { |
||
| 345 | return $this->show_detail; |
||
| 346 | } |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @param mixed $show_detail |
||
| 350 | * @return ColumnModel |
||
| 351 | */ |
||
| 352 | public function setShowDetail($show_detail) |
||
| 353 | { |
||
| 354 | $this->show_detail = $show_detail; |
||
| 355 | return $this; |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @return mixed |
||
| 360 | */ |
||
| 361 | public function getShowIndex() |
||
| 362 | { |
||
| 363 | return $this->show_index; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @param mixed $show_index |
||
| 368 | * @return ColumnModel |
||
| 369 | */ |
||
| 370 | public function setShowIndex($show_index) |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @return mixed |
||
| 378 | */ |
||
| 379 | public function getShowEdit() |
||
| 380 | { |
||
| 381 | return $this->show_edit; |
||
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * @param mixed $show_edit |
||
| 386 | * @return ColumnModel |
||
| 387 | */ |
||
| 388 | public function setShowEdit($show_edit) |
||
| 389 | { |
||
| 390 | $this->show_edit = $show_edit; |
||
| 391 | return $this; |
||
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @return mixed |
||
| 396 | */ |
||
| 397 | public function getShowAdd() |
||
| 398 | { |
||
| 399 | return $this->show_add; |
||
| 400 | } |
||
| 401 | |||
| 402 | /** |
||
| 403 | * @param mixed $show_add |
||
| 404 | * @return ColumnModel |
||
| 405 | */ |
||
| 406 | public function setShowAdd($show_add) |
||
| 407 | { |
||
| 408 | $this->show_add = $show_add; |
||
| 409 | return $this; |
||
| 410 | } |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @return mixed |
||
| 414 | */ |
||
| 415 | public function getVisible() |
||
| 416 | { |
||
| 417 | return $this->visible; |
||
| 418 | } |
||
| 419 | |||
| 420 | /** |
||
| 421 | * @param mixed $visible |
||
| 422 | * @return ColumnModel |
||
| 423 | */ |
||
| 424 | public function setVisible($visible) |
||
| 425 | { |
||
| 426 | $this->visible = $visible; |
||
| 427 | return $this; |
||
| 428 | } |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @return mixed |
||
| 432 | */ |
||
| 433 | public function getInputWidth() |
||
| 434 | { |
||
| 435 | return $this->input_width; |
||
| 436 | } |
||
| 437 | |||
| 438 | /** |
||
| 439 | * @param mixed $input_width |
||
| 440 | * @return ColumnModel |
||
| 441 | */ |
||
| 442 | public function setInputWidth($input_width) |
||
| 443 | { |
||
| 444 | $this->input_width = $input_width; |
||
| 445 | return $this; |
||
| 446 | } |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @return mixed |
||
| 450 | */ |
||
| 451 | public function getColumnWidth() |
||
| 452 | { |
||
| 453 | return $this->column_width; |
||
| 454 | } |
||
| 455 | |||
| 456 | /** |
||
| 457 | * @param mixed $column_width |
||
| 458 | * @return ColumnModel |
||
| 459 | */ |
||
| 460 | public function setColumnWidth($column_width) |
||
| 461 | { |
||
| 462 | $this->column_width = $column_width; |
||
| 463 | return $this; |
||
| 464 | } |
||
| 465 | |||
| 466 | /** |
||
| 467 | * @return mixed |
||
| 468 | */ |
||
| 469 | public function getRequired() |
||
| 470 | { |
||
| 471 | return $this->required; |
||
| 472 | } |
||
| 473 | |||
| 474 | /** |
||
| 475 | * @param mixed $required |
||
| 476 | * @return ColumnModel |
||
| 477 | */ |
||
| 478 | public function setRequired($required) |
||
| 479 | { |
||
| 480 | $this->required = $required; |
||
| 481 | return $this; |
||
| 482 | } |
||
| 483 | |||
| 484 | /** |
||
| 485 | * @return mixed |
||
| 486 | */ |
||
| 487 | public function getHelp() |
||
| 488 | { |
||
| 489 | return $this->help; |
||
| 490 | } |
||
| 491 | |||
| 492 | /** |
||
| 493 | * @param mixed $help |
||
| 494 | * @return ColumnModel |
||
| 495 | */ |
||
| 496 | public function setHelp($help) |
||
| 497 | { |
||
| 498 | $this->help = $help; |
||
| 499 | return $this; |
||
| 500 | } |
||
| 501 | |||
| 502 | /** |
||
| 503 | * @return mixed |
||
| 504 | */ |
||
| 505 | public function getPlaceholder() |
||
| 506 | { |
||
| 507 | return $this->placeholder; |
||
| 508 | } |
||
| 509 | |||
| 510 | /** |
||
| 511 | * @param mixed $placeholder |
||
| 512 | * @return ColumnModel |
||
| 513 | */ |
||
| 514 | public function setPlaceholder($placeholder) |
||
| 515 | { |
||
| 516 | $this->placeholder = $placeholder; |
||
| 517 | return $this; |
||
| 518 | } |
||
| 519 | |||
| 520 | /** |
||
| 521 | * @return mixed |
||
| 522 | */ |
||
| 523 | public function getValidation() |
||
| 524 | { |
||
| 525 | return $this->validation; |
||
| 526 | } |
||
| 527 | |||
| 528 | /** |
||
| 529 | * @param mixed $validation |
||
| 530 | * @return ColumnModel |
||
| 531 | */ |
||
| 532 | public function setValidation($validation) |
||
| 536 | } |
||
| 537 | |||
| 538 | /** |
||
| 539 | * @return mixed |
||
| 540 | */ |
||
| 541 | public function getValidationMessages() |
||
| 542 | { |
||
| 543 | return $this->validation_messages; |
||
| 544 | } |
||
| 545 | |||
| 546 | /** |
||
| 547 | * @param mixed $validation_messages |
||
| 548 | * @return ColumnModel |
||
| 549 | */ |
||
| 550 | public function setValidationMessages($validation_messages) |
||
| 551 | { |
||
| 552 | $this->validation_messages = $validation_messages; |
||
| 553 | return $this; |
||
| 554 | } |
||
| 555 | |||
| 556 | |||
| 557 | } |