Complex classes like DataTablesColumn 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 DataTablesColumn, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | final class DataTablesColumn implements JsonSerializable { |
||
26 | |||
27 | /** |
||
28 | * Cell type. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $cellType = "td"; |
||
33 | |||
34 | /** |
||
35 | * Class name. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $classname; |
||
40 | |||
41 | /** |
||
42 | * Content padding. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | private $contentPadding; |
||
47 | |||
48 | /** |
||
49 | * Data. |
||
50 | * |
||
51 | * @var integer|string |
||
52 | */ |
||
53 | private $data; |
||
54 | |||
55 | /** |
||
56 | * Default content. |
||
57 | * |
||
58 | * @var string |
||
59 | */ |
||
60 | private $defaultContent; |
||
61 | |||
62 | /** |
||
63 | * mapping. |
||
64 | * |
||
65 | * @var DataTablesMapping |
||
66 | */ |
||
67 | private $mapping; |
||
68 | |||
69 | /** |
||
70 | * Name. |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | private $name; |
||
75 | |||
76 | /** |
||
77 | * Order data. |
||
78 | * |
||
79 | * @var integer|array |
||
80 | */ |
||
81 | private $orderData; |
||
82 | |||
83 | /** |
||
84 | * Order data type. |
||
85 | * |
||
86 | * @var string |
||
87 | */ |
||
88 | private $orderDataType; |
||
89 | |||
90 | /** |
||
91 | * Order sequence. |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | private $orderSequence; |
||
96 | |||
97 | /** |
||
98 | * Orderable. |
||
99 | * |
||
100 | * @var boolean |
||
101 | */ |
||
102 | private $orderable = true; |
||
103 | |||
104 | /** |
||
105 | * Searchable. |
||
106 | * |
||
107 | * @var boolean |
||
108 | */ |
||
109 | private $searchable = true; |
||
110 | |||
111 | /** |
||
112 | * Title. |
||
113 | * |
||
114 | * @var string |
||
115 | */ |
||
116 | private $title; |
||
117 | |||
118 | /** |
||
119 | * Type. |
||
120 | * |
||
121 | * @var string |
||
122 | */ |
||
123 | private $type; |
||
124 | |||
125 | /** |
||
126 | * Visible. |
||
127 | * |
||
128 | * @var boolean |
||
129 | */ |
||
130 | private $visible = true; |
||
131 | |||
132 | /** |
||
133 | * Width. |
||
134 | * |
||
135 | * @var string |
||
136 | */ |
||
137 | private $width; |
||
138 | |||
139 | /** |
||
140 | * Constructor. |
||
141 | * |
||
142 | * @param string $name The column name. |
||
143 | * @param string $title The column title. |
||
144 | * @param string $cellType The column cell type. |
||
145 | */ |
||
146 | public function __construct($name, $title, $cellType = "td") { |
||
155 | |||
156 | /** |
||
157 | * Get the cell type. |
||
158 | * |
||
159 | * @return string Returns the cell type. |
||
160 | */ |
||
161 | public function getCellType() { |
||
164 | |||
165 | /** |
||
166 | * Get the class name. |
||
167 | * |
||
168 | * @return string Returns the class name. |
||
169 | */ |
||
170 | public function getClassname() { |
||
173 | |||
174 | /** |
||
175 | * Get the content padding. |
||
176 | * |
||
177 | * @return string Returns the content padding. |
||
178 | */ |
||
179 | public function getContentPadding() { |
||
182 | |||
183 | /** |
||
184 | * Get the data. |
||
185 | * |
||
186 | * @return integer|string Returns the data. |
||
187 | */ |
||
188 | public function getData() { |
||
191 | |||
192 | /** |
||
193 | * Get the default content |
||
194 | * |
||
195 | * @return string Returns the default content. |
||
196 | */ |
||
197 | public function getDefaultContent() { |
||
200 | |||
201 | /** |
||
202 | * Get the mapping. |
||
203 | * |
||
204 | * @return DataTablesMapping The mapping. |
||
205 | */ |
||
206 | public function getMapping() { |
||
209 | |||
210 | /** |
||
211 | * Get the name. |
||
212 | * |
||
213 | * @return string Returns the name. |
||
214 | */ |
||
215 | public function getName() { |
||
218 | |||
219 | /** |
||
220 | * Get the order data. |
||
221 | * |
||
222 | * @return integer|array Returns the order data. |
||
223 | */ |
||
224 | public function getOrderData() { |
||
227 | |||
228 | /** |
||
229 | * Get the order data type. |
||
230 | * |
||
231 | * @return string Returns the order data type. |
||
232 | */ |
||
233 | public function getOrderDataType() { |
||
236 | |||
237 | /** |
||
238 | * Get the order sequence. |
||
239 | * |
||
240 | * @return string Returns the order sequence. |
||
241 | */ |
||
242 | public function getOrderSequence() { |
||
245 | |||
246 | /** |
||
247 | * Get the orderable. |
||
248 | * |
||
249 | * @return boolean Returns the orderable. |
||
250 | */ |
||
251 | public function getOrderable() { |
||
254 | |||
255 | /** |
||
256 | * Get the searchable. |
||
257 | * |
||
258 | * @return boolean Returns the searchable. |
||
259 | */ |
||
260 | public function getSearchable() { |
||
263 | |||
264 | /** |
||
265 | * Get the title. |
||
266 | * |
||
267 | * @return string Returns the title. |
||
268 | */ |
||
269 | public function getTitle() { |
||
272 | |||
273 | /** |
||
274 | * Get the type. |
||
275 | * |
||
276 | * @return string Returns the type. |
||
277 | */ |
||
278 | public function getType() { |
||
281 | |||
282 | /** |
||
283 | * Get the visible. |
||
284 | * |
||
285 | * @return boolean Returns the visible. |
||
286 | */ |
||
287 | public function getVisible() { |
||
290 | |||
291 | /** |
||
292 | * Get the width. |
||
293 | * |
||
294 | * @return string Returns the width. |
||
295 | */ |
||
296 | public function getWidth() { |
||
299 | |||
300 | /** |
||
301 | * {@inheritdoc} |
||
302 | */ |
||
303 | public function jsonSerialize() { |
||
306 | |||
307 | /** |
||
308 | * Set the cell type. |
||
309 | * |
||
310 | * @param string $cellType The cell type. |
||
311 | * @return DataTablesColumn Returns the DataTables column. |
||
312 | */ |
||
313 | public function setCellType($cellType) { |
||
324 | |||
325 | /** |
||
326 | * Set the class name. |
||
327 | * |
||
328 | * @param string $classname The class name. |
||
329 | * @return DataTablesColumn Returns the DataTables column. |
||
330 | */ |
||
331 | public function setClassname($classname) { |
||
335 | |||
336 | /** |
||
337 | * Set the content padding. |
||
338 | * |
||
339 | * @param string $contentPadding The content padding. |
||
340 | * @return DataTablesColumn Returns the DataTables column. |
||
341 | */ |
||
342 | public function setContentPadding($contentPadding) { |
||
346 | |||
347 | /** |
||
348 | * Set the data. |
||
349 | * |
||
350 | * @param integer|string $data The data. |
||
351 | * @return DataTablesColumn Returns the DataTables column. |
||
352 | */ |
||
353 | public function setData($data) { |
||
357 | |||
358 | /** |
||
359 | * Set the default content. |
||
360 | * |
||
361 | * @param string $defaultContent The default content. |
||
362 | * @return DataTablesColumn Returns the DataTables column. |
||
363 | */ |
||
364 | public function setDefaultContent($defaultContent) { |
||
368 | |||
369 | /** |
||
370 | * Set the name. |
||
371 | * |
||
372 | * @param string $name The name. |
||
373 | * @return DataTablesColumn Returns the DataTables column. |
||
374 | */ |
||
375 | public function setName($name) { |
||
379 | |||
380 | /** |
||
381 | * Set the order data. |
||
382 | * |
||
383 | * @param integer|array $orderData The order data. |
||
384 | * @return DataTablesColumn Returns the DataTables column. |
||
385 | */ |
||
386 | public function setOrderData($orderData) { |
||
390 | |||
391 | /** |
||
392 | * Set the order data type. |
||
393 | * |
||
394 | * @param string $orderDataType The order data type. |
||
395 | * @return DataTablesColumn Returns the DataTables column. |
||
396 | */ |
||
397 | public function setOrderDataType($orderDataType) { |
||
401 | |||
402 | /** |
||
403 | * Set the order sequence. |
||
404 | * |
||
405 | * @param string $orderSequence The order sequence. |
||
406 | * @return DataTablesColumn Returns the DataTables column. |
||
407 | */ |
||
408 | public function setOrderSequence($orderSequence) { |
||
419 | |||
420 | /** |
||
421 | * Set the orderable. |
||
422 | * |
||
423 | * @param boolean $orderable The orderable. |
||
424 | * @return DataTablesColumn Returns the DataTables column. |
||
425 | */ |
||
426 | public function setOrderable($orderable) { |
||
430 | |||
431 | /** |
||
432 | * Set the searchable. |
||
433 | * |
||
434 | * @param boolean $searchable The searchable. |
||
435 | * @return DataTablesColumn Returns the DataTables column. |
||
436 | */ |
||
437 | public function setSearchable($searchable) { |
||
441 | |||
442 | /** |
||
443 | * Set the title. |
||
444 | * |
||
445 | * @param string $title The title. |
||
446 | * @return DataTablesColumn Returns the DataTables column. |
||
447 | */ |
||
448 | public function setTitle($title) { |
||
452 | |||
453 | /** |
||
454 | * Set the type. |
||
455 | * |
||
456 | * @param string $type The type. |
||
457 | * @return DataTablesColumn Returns the DataTables column. |
||
458 | */ |
||
459 | public function setType($type) { |
||
474 | |||
475 | /** |
||
476 | * Set the visible. |
||
477 | * |
||
478 | * @param boolean $visible The visible. |
||
479 | * @return DataTablesColumn Returns the DataTables column. |
||
480 | */ |
||
481 | public function setVisible($visible) { |
||
485 | |||
486 | /** |
||
487 | * Set the width. |
||
488 | * |
||
489 | * @param string $width The width. |
||
490 | * @return DataTablesColumn Returns the DataTables column. |
||
491 | */ |
||
492 | public function setWidth($width) { |
||
496 | |||
497 | /** |
||
498 | * Convert into an array representing this instance. |
||
499 | * |
||
500 | * @return array Returns an array representing this instance. |
||
501 | */ |
||
502 | public function toArray() { |
||
526 | |||
527 | } |
||
528 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.