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