Complex classes like DrillDownComparisonParams 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 DrillDownComparisonParams, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
7 | class DrillDownComparisonParams extends Model |
||
8 | { |
||
9 | |||
10 | protected $id = null; |
||
11 | |||
12 | protected $metrics = null; |
||
13 | |||
14 | protected $accuracy = null; |
||
15 | |||
16 | protected $callback = null; |
||
17 | |||
18 | protected $date1A = null; |
||
19 | |||
20 | protected $date1B = null; |
||
21 | |||
22 | protected $date2A = null; |
||
23 | |||
24 | protected $date2B = null; |
||
25 | |||
26 | protected $dimensions = null; |
||
27 | |||
28 | protected $filters = null; |
||
29 | |||
30 | protected $filtersA = null; |
||
31 | |||
32 | protected $filtersB = null; |
||
33 | |||
34 | protected $includeUndefined = null; |
||
35 | |||
36 | protected $lang = null; |
||
37 | |||
38 | protected $limit = null; |
||
39 | |||
40 | protected $offset = null; |
||
41 | |||
42 | protected $preset = null; |
||
43 | |||
44 | protected $pretty = null; |
||
45 | |||
46 | protected $sort = null; |
||
47 | |||
48 | protected $parentId = null; |
||
49 | |||
50 | protected $mappingClasses = []; |
||
51 | |||
52 | protected $propNameMap = [ |
||
53 | 'date1_a' => 'date1A', |
||
54 | 'date1_b' => 'date1B', |
||
55 | 'date2_a' => 'date2A', |
||
56 | 'date2_b' => 'date2B', |
||
57 | 'filters_a' => 'filtersA', |
||
58 | 'filters_b' => 'filtersB', |
||
59 | 'include_undefined' => 'includeUndefined', |
||
60 | 'parent_id' => 'parentId' |
||
61 | ]; |
||
62 | |||
63 | /** |
||
64 | * Retrieve the id property |
||
65 | * |
||
66 | * @return int|null |
||
67 | */ |
||
68 | 1 | public function getId() |
|
72 | |||
73 | /** |
||
74 | * Set the id property |
||
75 | * |
||
76 | * @param int $id |
||
77 | * @return $this |
||
78 | */ |
||
79 | 1 | public function setId($id) |
|
84 | |||
85 | /** |
||
86 | * Retrieve the metrics property |
||
87 | * |
||
88 | * @return string|null |
||
89 | */ |
||
90 | 1 | public function getMetrics() |
|
94 | |||
95 | /** |
||
96 | * Set the metrics property |
||
97 | * |
||
98 | * @param string $metrics |
||
99 | * @return $this |
||
100 | */ |
||
101 | 1 | public function setMetrics($metrics) |
|
106 | |||
107 | /** |
||
108 | * Retrieve the accuracy property |
||
109 | * |
||
110 | * @return string|null |
||
111 | */ |
||
112 | 1 | public function getAccuracy() |
|
116 | |||
117 | /** |
||
118 | * Set the accuracy property |
||
119 | * |
||
120 | * @param string $accuracy |
||
121 | * @return $this |
||
122 | */ |
||
123 | 1 | public function setAccuracy($accuracy) |
|
128 | |||
129 | /** |
||
130 | * Retrieve the callback property |
||
131 | * |
||
132 | * @return string|null |
||
133 | */ |
||
134 | 1 | public function getCallback() |
|
138 | |||
139 | /** |
||
140 | * Set the callback property |
||
141 | * |
||
142 | * @param string $callback |
||
143 | * @return $this |
||
144 | */ |
||
145 | 1 | public function setCallback($callback) |
|
150 | |||
151 | /** |
||
152 | * Retrieve the date1A property |
||
153 | * |
||
154 | * @return string|null |
||
155 | */ |
||
156 | 1 | public function getDate1A() |
|
160 | |||
161 | /** |
||
162 | * Set the date1A property |
||
163 | * |
||
164 | * @param string $date1A |
||
165 | * @return $this |
||
166 | */ |
||
167 | 1 | public function setDate1A($date1A) |
|
172 | |||
173 | /** |
||
174 | * Retrieve the date1B property |
||
175 | * |
||
176 | * @return string|null |
||
177 | */ |
||
178 | 1 | public function getDate1B() |
|
182 | |||
183 | /** |
||
184 | * Set the date1B property |
||
185 | * |
||
186 | * @param string $date1B |
||
187 | * @return $this |
||
188 | */ |
||
189 | 1 | public function setDate1B($date1B) |
|
194 | |||
195 | /** |
||
196 | * Retrieve the date2A property |
||
197 | * |
||
198 | * @return string|null |
||
199 | */ |
||
200 | 1 | public function getDate2A() |
|
204 | |||
205 | /** |
||
206 | * Set the date2A property |
||
207 | * |
||
208 | * @param string $date2A |
||
209 | * @return $this |
||
210 | */ |
||
211 | 1 | public function setDate2A($date2A) |
|
216 | |||
217 | /** |
||
218 | * Retrieve the date2B property |
||
219 | * |
||
220 | * @return string|null |
||
221 | */ |
||
222 | 1 | public function getDate2B() |
|
226 | |||
227 | /** |
||
228 | * Set the date2B property |
||
229 | * |
||
230 | * @param string $date2B |
||
231 | * @return $this |
||
232 | */ |
||
233 | 1 | public function setDate2B($date2B) |
|
238 | |||
239 | /** |
||
240 | * Retrieve the dimensions property |
||
241 | * |
||
242 | * @return string|null |
||
243 | */ |
||
244 | 1 | public function getDimensions() |
|
248 | |||
249 | /** |
||
250 | * Set the dimensions property |
||
251 | * |
||
252 | * @param string $dimensions |
||
253 | * @return $this |
||
254 | */ |
||
255 | 1 | public function setDimensions($dimensions) |
|
260 | |||
261 | /** |
||
262 | * Retrieve the filters property |
||
263 | * |
||
264 | * @return string|null |
||
265 | */ |
||
266 | 1 | public function getFilters() |
|
270 | |||
271 | /** |
||
272 | * Set the filters property |
||
273 | * |
||
274 | * @param string $filters |
||
275 | * @return $this |
||
276 | */ |
||
277 | 1 | public function setFilters($filters) |
|
282 | |||
283 | /** |
||
284 | * Retrieve the filtersA property |
||
285 | * |
||
286 | * @return string|null |
||
287 | */ |
||
288 | 1 | public function getFiltersA() |
|
292 | |||
293 | /** |
||
294 | * Set the filtersA property |
||
295 | * |
||
296 | * @param string $filtersA |
||
297 | * @return $this |
||
298 | */ |
||
299 | 1 | public function setFiltersA($filtersA) |
|
304 | |||
305 | /** |
||
306 | * Retrieve the filtersB property |
||
307 | * |
||
308 | * @return string|null |
||
309 | */ |
||
310 | 1 | public function getFiltersB() |
|
314 | |||
315 | /** |
||
316 | * Set the filtersB property |
||
317 | * |
||
318 | * @param string $filtersB |
||
319 | * @return $this |
||
320 | */ |
||
321 | 1 | public function setFiltersB($filtersB) |
|
326 | |||
327 | /** |
||
328 | * Retrieve the includeUndefined property |
||
329 | * |
||
330 | * @return bool|null |
||
331 | */ |
||
332 | 1 | public function getIncludeUndefined() |
|
336 | |||
337 | /** |
||
338 | * Set the includeUndefined property |
||
339 | * |
||
340 | * @param bool $includeUndefined |
||
341 | * @return $this |
||
342 | */ |
||
343 | 1 | public function setIncludeUndefined($includeUndefined) |
|
348 | |||
349 | /** |
||
350 | * Retrieve the lang property |
||
351 | * |
||
352 | * @return string|null |
||
353 | */ |
||
354 | 1 | public function getLang() |
|
358 | |||
359 | /** |
||
360 | * Set the lang property |
||
361 | * |
||
362 | * @param string $lang |
||
363 | * @return $this |
||
364 | */ |
||
365 | 1 | public function setLang($lang) |
|
370 | |||
371 | /** |
||
372 | * Retrieve the limit property |
||
373 | * |
||
374 | * @return int|null |
||
375 | */ |
||
376 | 1 | public function getLimit() |
|
380 | |||
381 | /** |
||
382 | * Set the limit property |
||
383 | * |
||
384 | * @param int $limit |
||
385 | * @return $this |
||
386 | */ |
||
387 | 1 | public function setLimit($limit) |
|
392 | |||
393 | /** |
||
394 | * Retrieve the offset property |
||
395 | * |
||
396 | * @return int|null |
||
397 | */ |
||
398 | 1 | public function getOffset() |
|
402 | |||
403 | /** |
||
404 | * Set the offset property |
||
405 | * |
||
406 | * @param int $offset |
||
407 | * @return $this |
||
408 | */ |
||
409 | 1 | public function setOffset($offset) |
|
414 | |||
415 | /** |
||
416 | * Retrieve the preset property |
||
417 | * |
||
418 | * @return string|null |
||
419 | */ |
||
420 | 1 | public function getPreset() |
|
424 | |||
425 | /** |
||
426 | * Set the preset property |
||
427 | * |
||
428 | * @param string $preset |
||
429 | * @return $this |
||
430 | */ |
||
431 | 1 | public function setPreset($preset) |
|
436 | |||
437 | /** |
||
438 | * Retrieve the pretty property |
||
439 | * |
||
440 | * @return bool|null |
||
441 | */ |
||
442 | 1 | public function getPretty() |
|
446 | |||
447 | /** |
||
448 | * Set the pretty property |
||
449 | * |
||
450 | * @param bool $pretty |
||
451 | * @return $this |
||
452 | */ |
||
453 | 1 | public function setPretty($pretty) |
|
458 | |||
459 | /** |
||
460 | * Retrieve the sort property |
||
461 | * |
||
462 | * @return string|null |
||
463 | */ |
||
464 | 1 | public function getSort() |
|
468 | |||
469 | /** |
||
470 | * Set the sort property |
||
471 | * |
||
472 | * @param string $sort |
||
473 | * @return $this |
||
474 | */ |
||
475 | 1 | public function setSort($sort) |
|
480 | |||
481 | /** |
||
482 | * Retrieve the parentId property |
||
483 | * |
||
484 | * @return string|null |
||
485 | */ |
||
486 | 1 | public function getParentId() |
|
490 | |||
491 | /** |
||
492 | * Set the parentId property |
||
493 | * |
||
494 | * @param string $parentId |
||
495 | * @return $this |
||
496 | */ |
||
497 | 1 | public function setParentId($parentId) |
|
502 | } |
||
503 |