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