| Total Complexity | 46 |
| Total Lines | 434 |
| 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 | |||
| 37 | private $index_display_transform; |
||
| 38 | private $detail_display_transform; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return mixed |
||
| 42 | */ |
||
| 43 | public function getIndexDisplayTransform() |
||
| 44 | { |
||
| 45 | return $this->index_display_transform; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param mixed $index_display_transform |
||
| 50 | */ |
||
| 51 | public function setIndexDisplayTransform($index_display_transform) |
||
| 52 | { |
||
| 53 | $this->index_display_transform = $index_display_transform; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return mixed |
||
| 58 | */ |
||
| 59 | public function getDetailDisplayTransform() |
||
| 60 | { |
||
| 61 | return $this->detail_display_transform; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @param mixed $detail_display_transform |
||
| 66 | */ |
||
| 67 | public function setDetailDisplayTransform($detail_display_transform) |
||
| 68 | { |
||
| 69 | $this->detail_display_transform = $detail_display_transform; |
||
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | /** |
||
| 75 | * @return mixed |
||
| 76 | */ |
||
| 77 | public function getDefaultValue() |
||
| 78 | { |
||
| 79 | return $this->default_value; |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @param mixed $default_value |
||
| 84 | */ |
||
| 85 | public function setDefaultValue($default_value): void |
||
| 86 | { |
||
| 87 | $this->default_value = $default_value; |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @return mixed |
||
| 92 | */ |
||
| 93 | public function getDisabled() |
||
| 94 | { |
||
| 95 | return $this->disabled; |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @param mixed $disabled |
||
| 100 | */ |
||
| 101 | public function setDisabled($disabled): void |
||
| 102 | { |
||
| 103 | $this->disabled = $disabled; |
||
| 104 | } |
||
| 105 | |||
| 106 | |||
| 107 | /** |
||
| 108 | * @return mixed |
||
| 109 | */ |
||
| 110 | public function getReadonly() |
||
| 111 | { |
||
| 112 | return $this->readonly; |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @param mixed $readonly |
||
| 117 | */ |
||
| 118 | public function setReadonly($readonly): void |
||
| 119 | { |
||
| 120 | $this->readonly = $readonly; |
||
| 121 | } |
||
| 122 | |||
| 123 | |||
| 124 | /** |
||
| 125 | * @return mixed |
||
| 126 | */ |
||
| 127 | public function getStyle() |
||
| 128 | { |
||
| 129 | return $this->style; |
||
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @param mixed $style |
||
| 134 | */ |
||
| 135 | public function setStyle($style): void |
||
| 136 | { |
||
| 137 | $this->style = $style; |
||
| 138 | } |
||
| 139 | |||
| 140 | |||
| 141 | /** |
||
| 142 | * @return mixed |
||
| 143 | */ |
||
| 144 | public function getValue() |
||
| 145 | { |
||
| 146 | return $this->value; |
||
| 147 | } |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @param mixed $value |
||
| 151 | * @return ColumnModel |
||
| 152 | */ |
||
| 153 | public function setValue($value) |
||
| 154 | { |
||
| 155 | $this->value = $value; |
||
| 156 | return $this; |
||
| 157 | } |
||
| 158 | |||
| 159 | |||
| 160 | /** |
||
| 161 | * @return mixed |
||
| 162 | */ |
||
| 163 | public function getLabel() |
||
| 164 | { |
||
| 165 | return $this->label; |
||
| 166 | } |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @param mixed $label |
||
| 170 | * @return ColumnModel |
||
| 171 | */ |
||
| 172 | public function setLabel($label) |
||
| 173 | { |
||
| 174 | $this->label = $label; |
||
| 175 | return $this; |
||
| 176 | } |
||
| 177 | |||
| 178 | /** |
||
| 179 | * @return mixed |
||
| 180 | */ |
||
| 181 | public function getName() |
||
| 182 | { |
||
| 183 | return $this->name; |
||
| 184 | } |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @param mixed $name |
||
| 188 | * @return ColumnModel |
||
| 189 | */ |
||
| 190 | public function setName($name) |
||
| 191 | { |
||
| 192 | $this->name = $name; |
||
| 193 | return $this; |
||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * @return mixed |
||
| 198 | */ |
||
| 199 | public function getField() |
||
| 200 | { |
||
| 201 | return $this->field; |
||
| 202 | } |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @param mixed $field |
||
| 206 | * @return ColumnModel |
||
| 207 | */ |
||
| 208 | public function setField($field) |
||
| 212 | } |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @return mixed |
||
| 216 | */ |
||
| 217 | public function getType() |
||
| 218 | { |
||
| 219 | return $this->type; |
||
| 220 | } |
||
| 221 | |||
| 222 | /** |
||
| 223 | * @param mixed $type |
||
| 224 | * @return ColumnModel |
||
| 225 | */ |
||
| 226 | public function setType($type) |
||
| 227 | { |
||
| 228 | $this->type = $type; |
||
| 229 | return $this; |
||
| 230 | } |
||
| 231 | |||
| 232 | /** |
||
| 233 | * @return mixed |
||
| 234 | */ |
||
| 235 | public function getShowDetail() |
||
| 236 | { |
||
| 237 | return $this->show_detail; |
||
| 238 | } |
||
| 239 | |||
| 240 | /** |
||
| 241 | * @param mixed $show_detail |
||
| 242 | * @return ColumnModel |
||
| 243 | */ |
||
| 244 | public function setShowDetail($show_detail) |
||
| 245 | { |
||
| 246 | $this->show_detail = $show_detail; |
||
| 247 | return $this; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * @return mixed |
||
| 252 | */ |
||
| 253 | public function getShowIndex() |
||
| 254 | { |
||
| 255 | return $this->show_index; |
||
| 256 | } |
||
| 257 | |||
| 258 | /** |
||
| 259 | * @param mixed $show_index |
||
| 260 | * @return ColumnModel |
||
| 261 | */ |
||
| 262 | public function setShowIndex($show_index) |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * @return mixed |
||
| 270 | */ |
||
| 271 | public function getShowEdit() |
||
| 272 | { |
||
| 273 | return $this->show_edit; |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @param mixed $show_edit |
||
| 278 | * @return ColumnModel |
||
| 279 | */ |
||
| 280 | public function setShowEdit($show_edit) |
||
| 281 | { |
||
| 282 | $this->show_edit = $show_edit; |
||
| 283 | return $this; |
||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * @return mixed |
||
| 288 | */ |
||
| 289 | public function getShowAdd() |
||
| 290 | { |
||
| 291 | return $this->show_add; |
||
| 292 | } |
||
| 293 | |||
| 294 | /** |
||
| 295 | * @param mixed $show_add |
||
| 296 | * @return ColumnModel |
||
| 297 | */ |
||
| 298 | public function setShowAdd($show_add) |
||
| 299 | { |
||
| 300 | $this->show_add = $show_add; |
||
| 301 | return $this; |
||
| 302 | } |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @return mixed |
||
| 306 | */ |
||
| 307 | public function getVisible() |
||
| 308 | { |
||
| 309 | return $this->visible; |
||
| 310 | } |
||
| 311 | |||
| 312 | /** |
||
| 313 | * @param mixed $visible |
||
| 314 | * @return ColumnModel |
||
| 315 | */ |
||
| 316 | public function setVisible($visible) |
||
| 317 | { |
||
| 318 | $this->visible = $visible; |
||
| 319 | return $this; |
||
| 320 | } |
||
| 321 | |||
| 322 | /** |
||
| 323 | * @return mixed |
||
| 324 | */ |
||
| 325 | public function getInputWidth() |
||
| 326 | { |
||
| 327 | return $this->input_width; |
||
| 328 | } |
||
| 329 | |||
| 330 | /** |
||
| 331 | * @param mixed $input_width |
||
| 332 | * @return ColumnModel |
||
| 333 | */ |
||
| 334 | public function setInputWidth($input_width) |
||
| 335 | { |
||
| 336 | $this->input_width = $input_width; |
||
| 337 | return $this; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @return mixed |
||
| 342 | */ |
||
| 343 | public function getColumnWidth() |
||
| 344 | { |
||
| 345 | return $this->column_width; |
||
| 346 | } |
||
| 347 | |||
| 348 | /** |
||
| 349 | * @param mixed $column_width |
||
| 350 | * @return ColumnModel |
||
| 351 | */ |
||
| 352 | public function setColumnWidth($column_width) |
||
| 353 | { |
||
| 354 | $this->column_width = $column_width; |
||
| 355 | return $this; |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * @return mixed |
||
| 360 | */ |
||
| 361 | public function getRequired() |
||
| 362 | { |
||
| 363 | return $this->required; |
||
| 364 | } |
||
| 365 | |||
| 366 | /** |
||
| 367 | * @param mixed $required |
||
| 368 | * @return ColumnModel |
||
| 369 | */ |
||
| 370 | public function setRequired($required) |
||
| 371 | { |
||
| 372 | $this->required = $required; |
||
| 373 | return $this; |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @return mixed |
||
| 378 | */ |
||
| 379 | public function getHelp() |
||
| 380 | { |
||
| 381 | return $this->help; |
||
| 382 | } |
||
| 383 | |||
| 384 | /** |
||
| 385 | * @param mixed $help |
||
| 386 | * @return ColumnModel |
||
| 387 | */ |
||
| 388 | public function setHelp($help) |
||
| 392 | } |
||
| 393 | |||
| 394 | /** |
||
| 395 | * @return mixed |
||
| 396 | */ |
||
| 397 | public function getPlaceholder() |
||
| 398 | { |
||
| 399 | return $this->placeholder; |
||
| 400 | } |
||
| 401 | |||
| 402 | /** |
||
| 403 | * @param mixed $placeholder |
||
| 404 | * @return ColumnModel |
||
| 405 | */ |
||
| 406 | public function setPlaceholder($placeholder) |
||
| 407 | { |
||
| 408 | $this->placeholder = $placeholder; |
||
| 409 | return $this; |
||
| 410 | } |
||
| 411 | |||
| 412 | /** |
||
| 413 | * @return mixed |
||
| 414 | */ |
||
| 415 | public function getValidation() |
||
| 416 | { |
||
| 417 | return $this->validation; |
||
| 418 | } |
||
| 419 | |||
| 420 | /** |
||
| 421 | * @param mixed $validation |
||
| 422 | * @return ColumnModel |
||
| 423 | */ |
||
| 424 | public function setValidation($validation) |
||
| 428 | } |
||
| 429 | |||
| 430 | /** |
||
| 431 | * @return mixed |
||
| 432 | */ |
||
| 433 | public function getValidationMessages() |
||
| 434 | { |
||
| 435 | return $this->validation_messages; |
||
| 436 | } |
||
| 437 | |||
| 438 | /** |
||
| 439 | * @param mixed $validation_messages |
||
| 440 | * @return ColumnModel |
||
| 441 | */ |
||
| 442 | public function setValidationMessages($validation_messages) |
||
| 443 | { |
||
| 444 | $this->validation_messages = $validation_messages; |
||
| 445 | return $this; |
||
| 446 | } |
||
| 447 | |||
| 448 | |||
| 449 | } |