Complex classes like ExtendCounter 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 ExtendCounter, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
14 | class ExtendCounter extends Model |
||
15 | { |
||
16 | |||
17 | protected $id = null; |
||
18 | |||
19 | protected $ownerLogin = null; |
||
20 | |||
21 | protected $codeStatus = null; |
||
22 | |||
23 | protected $name = null; |
||
24 | |||
25 | protected $site = null; |
||
26 | |||
27 | protected $type = null; |
||
28 | |||
29 | protected $permission = null; |
||
30 | |||
31 | protected $webvisor = null; |
||
32 | |||
33 | protected $codeOptions = null; |
||
34 | |||
35 | protected $mirrors = null; |
||
36 | |||
37 | protected $goals = null; |
||
38 | |||
39 | protected $filters = null; |
||
40 | |||
41 | protected $operations = null; |
||
42 | |||
43 | protected $grants = null; |
||
44 | |||
45 | protected $monitoring = null; |
||
46 | |||
47 | protected $filterRobots = null; |
||
48 | |||
49 | protected $timeZoneName = null; |
||
50 | |||
51 | protected $visitThreshoId = null; |
||
52 | |||
53 | protected $code = null; |
||
54 | |||
55 | protected $accuracy = null; |
||
56 | |||
57 | protected $callback = null; |
||
58 | |||
59 | protected $includeUndefined = null; |
||
60 | |||
61 | protected $sort = null; |
||
62 | |||
63 | protected $lang = null; |
||
64 | |||
65 | protected $mappingClasses = [ |
||
66 | 'webvisor' => 'Yandex\Metrica\Management\Models\Webvisor', |
||
67 | 'codeOptions' => 'Yandex\Metrica\Management\Models\CodeOptions', |
||
68 | 'goals' => 'Yandex\Metrica\Management\Models\Goals', |
||
69 | 'filters' => 'Yandex\Metrica\Management\Models\Filters', |
||
70 | 'operations' => 'Yandex\Metrica\Management\Models\Operations', |
||
71 | 'grants' => 'Yandex\Metrica\Management\Models\Grants', |
||
72 | 'monitoring' => 'Yandex\Metrica\Management\Models\Monitoring' |
||
73 | ]; |
||
74 | |||
75 | protected $propNameMap = [ |
||
76 | 'owner_login' => 'ownerLogin', |
||
77 | 'code_status' => 'codeStatus', |
||
78 | 'code_options' => 'codeOptions', |
||
79 | 'filter_robots' => 'filterRobots', |
||
80 | 'time_zone_name' => 'timeZoneName', |
||
81 | 'visit_thresho_id' => 'visitThreshoId', |
||
82 | 'include_undefined' => 'includeUndefined' |
||
83 | ]; |
||
84 | |||
85 | /** |
||
86 | * Retrieve the id property |
||
87 | * |
||
88 | * @return int|null |
||
89 | */ |
||
90 | public function getId() |
||
94 | |||
95 | /** |
||
96 | * Set the id property |
||
97 | * |
||
98 | * @param int $id |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function setId($id) |
||
106 | |||
107 | /** |
||
108 | * Retrieve the ownerLogin property |
||
109 | * |
||
110 | * @return string|null |
||
111 | */ |
||
112 | public function getOwnerLogin() |
||
116 | |||
117 | /** |
||
118 | * Set the ownerLogin property |
||
119 | * |
||
120 | * @param string $ownerLogin |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function setOwnerLogin($ownerLogin) |
||
128 | |||
129 | /** |
||
130 | * Retrieve the codeStatus property |
||
131 | * |
||
132 | * @return string|null |
||
133 | */ |
||
134 | public function getCodeStatus() |
||
138 | |||
139 | /** |
||
140 | * Set the codeStatus property |
||
141 | * |
||
142 | * @param string $codeStatus |
||
143 | * @return $this |
||
144 | */ |
||
145 | public function setCodeStatus($codeStatus) |
||
150 | |||
151 | /** |
||
152 | * Retrieve the name property |
||
153 | * |
||
154 | * @return string|null |
||
155 | */ |
||
156 | public function getName() |
||
160 | |||
161 | /** |
||
162 | * Set the name property |
||
163 | * |
||
164 | * @param string $name |
||
165 | * @return $this |
||
166 | */ |
||
167 | public function setName($name) |
||
172 | |||
173 | /** |
||
174 | * Retrieve the site property |
||
175 | * |
||
176 | * @return string|null |
||
177 | */ |
||
178 | public function getSite() |
||
182 | |||
183 | /** |
||
184 | * Set the site property |
||
185 | * |
||
186 | * @param string $site |
||
187 | * @return $this |
||
188 | */ |
||
189 | public function setSite($site) |
||
194 | |||
195 | /** |
||
196 | * Retrieve the type property |
||
197 | * |
||
198 | * @return string|null |
||
199 | */ |
||
200 | public function getType() |
||
204 | |||
205 | /** |
||
206 | * Set the type property |
||
207 | * |
||
208 | * @param string $type |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function setType($type) |
||
216 | |||
217 | /** |
||
218 | * Retrieve the permission property |
||
219 | * |
||
220 | * @return string|null |
||
221 | */ |
||
222 | public function getPermission() |
||
226 | |||
227 | /** |
||
228 | * Set the permission property |
||
229 | * |
||
230 | * @param string $permission |
||
231 | * @return $this |
||
232 | */ |
||
233 | public function setPermission($permission) |
||
238 | |||
239 | /** |
||
240 | * Retrieve the webvisor property |
||
241 | * |
||
242 | * @return Webvisor|null |
||
243 | */ |
||
244 | public function getWebvisor() |
||
248 | |||
249 | /** |
||
250 | * Set the webvisor property |
||
251 | * |
||
252 | * @param Webvisor $webvisor |
||
253 | * @return $this |
||
254 | */ |
||
255 | public function setWebvisor($webvisor) |
||
260 | |||
261 | /** |
||
262 | * Retrieve the codeOptions property |
||
263 | * |
||
264 | * @return CodeOptions|null |
||
265 | */ |
||
266 | public function getCodeOptions() |
||
270 | |||
271 | /** |
||
272 | * Set the codeOptions property |
||
273 | * |
||
274 | * @param CodeOptions $codeOptions |
||
275 | * @return $this |
||
276 | */ |
||
277 | public function setCodeOptions($codeOptions) |
||
282 | |||
283 | /** |
||
284 | * Retrieve the mirrors property |
||
285 | * |
||
286 | * @return array|null |
||
287 | */ |
||
288 | public function getMirrors() |
||
292 | |||
293 | /** |
||
294 | * Set the mirrors property |
||
295 | * |
||
296 | * @param array $mirrors |
||
297 | * @return $this |
||
298 | */ |
||
299 | public function setMirrors($mirrors) |
||
304 | |||
305 | /** |
||
306 | * Retrieve the goals property |
||
307 | * |
||
308 | * @return Goals|null |
||
309 | */ |
||
310 | public function getGoals() |
||
314 | |||
315 | /** |
||
316 | * Set the goals property |
||
317 | * |
||
318 | * @param Goals $goals |
||
319 | * @return $this |
||
320 | */ |
||
321 | public function setGoals($goals) |
||
326 | |||
327 | /** |
||
328 | * Retrieve the filters property |
||
329 | * |
||
330 | * @return Filters|null |
||
331 | */ |
||
332 | public function getFilters() |
||
336 | |||
337 | /** |
||
338 | * Set the filters property |
||
339 | * |
||
340 | * @param Filters $filters |
||
341 | * @return $this |
||
342 | */ |
||
343 | public function setFilters($filters) |
||
348 | |||
349 | /** |
||
350 | * Retrieve the operations property |
||
351 | * |
||
352 | * @return Operations|null |
||
353 | */ |
||
354 | public function getOperations() |
||
358 | |||
359 | /** |
||
360 | * Set the operations property |
||
361 | * |
||
362 | * @param Operations $operations |
||
363 | * @return $this |
||
364 | */ |
||
365 | public function setOperations($operations) |
||
370 | |||
371 | /** |
||
372 | * Retrieve the grants property |
||
373 | * |
||
374 | * @return Grants|null |
||
375 | */ |
||
376 | public function getGrants() |
||
380 | |||
381 | /** |
||
382 | * Set the grants property |
||
383 | * |
||
384 | * @param Grants $grants |
||
385 | * @return $this |
||
386 | */ |
||
387 | public function setGrants($grants) |
||
392 | |||
393 | /** |
||
394 | * Retrieve the monitoring property |
||
395 | * |
||
396 | * @return Monitoring|null |
||
397 | */ |
||
398 | public function getMonitoring() |
||
402 | |||
403 | /** |
||
404 | * Set the monitoring property |
||
405 | * |
||
406 | * @param Monitoring $monitoring |
||
407 | * @return $this |
||
408 | */ |
||
409 | public function setMonitoring($monitoring) |
||
414 | |||
415 | /** |
||
416 | * Retrieve the filterRobots property |
||
417 | * |
||
418 | * @return int|null |
||
419 | */ |
||
420 | public function getFilterRobots() |
||
424 | |||
425 | /** |
||
426 | * Set the filterRobots property |
||
427 | * |
||
428 | * @param int $filterRobots |
||
429 | * @return $this |
||
430 | */ |
||
431 | public function setFilterRobots($filterRobots) |
||
436 | |||
437 | /** |
||
438 | * Retrieve the timeZoneName property |
||
439 | * |
||
440 | * @return string|null |
||
441 | */ |
||
442 | public function getTimeZoneName() |
||
446 | |||
447 | /** |
||
448 | * Set the timeZoneName property |
||
449 | * |
||
450 | * @param string $timeZoneName |
||
451 | * @return $this |
||
452 | */ |
||
453 | public function setTimeZoneName($timeZoneName) |
||
458 | |||
459 | /** |
||
460 | * Retrieve the visitThreshoId property |
||
461 | * |
||
462 | * @return int|null |
||
463 | */ |
||
464 | public function getVisitThreshoId() |
||
468 | |||
469 | /** |
||
470 | * Set the visitThreshoId property |
||
471 | * |
||
472 | * @param int $visitThreshoId |
||
473 | * @return $this |
||
474 | */ |
||
475 | public function setVisitThreshoId($visitThreshoId) |
||
480 | |||
481 | /** |
||
482 | * Retrieve the code property |
||
483 | * |
||
484 | * @return string|null |
||
485 | */ |
||
486 | public function getCode() |
||
490 | |||
491 | /** |
||
492 | * Set the code property |
||
493 | * |
||
494 | * @param string $code |
||
495 | * @return $this |
||
496 | */ |
||
497 | public function setCode($code) |
||
502 | |||
503 | /** |
||
504 | * Retrieve the accuracy property |
||
505 | * |
||
506 | * @return string|null |
||
507 | */ |
||
508 | public function getAccuracy() |
||
512 | |||
513 | /** |
||
514 | * Set the accuracy property |
||
515 | * |
||
516 | * @param string $accuracy |
||
517 | * @return $this |
||
518 | */ |
||
519 | public function setAccuracy($accuracy) |
||
524 | |||
525 | /** |
||
526 | * Retrieve the callback property |
||
527 | * |
||
528 | * @return string|null |
||
529 | */ |
||
530 | public function getCallback() |
||
534 | |||
535 | /** |
||
536 | * Set the callback property |
||
537 | * |
||
538 | * @param string $callback |
||
539 | * @return $this |
||
540 | */ |
||
541 | public function setCallback($callback) |
||
546 | |||
547 | /** |
||
548 | * Retrieve the includeUndefined property |
||
549 | * |
||
550 | * @return bool|null |
||
551 | */ |
||
552 | public function getIncludeUndefined() |
||
556 | |||
557 | /** |
||
558 | * Set the includeUndefined property |
||
559 | * |
||
560 | * @param bool $includeUndefined |
||
561 | * @return $this |
||
562 | */ |
||
563 | public function setIncludeUndefined($includeUndefined) |
||
568 | |||
569 | /** |
||
570 | * Retrieve the sort property |
||
571 | * |
||
572 | * @return string|null |
||
573 | */ |
||
574 | public function getSort() |
||
578 | |||
579 | /** |
||
580 | * Set the sort property |
||
581 | * |
||
582 | * @param string $sort |
||
583 | * @return $this |
||
584 | */ |
||
585 | public function setSort($sort) |
||
590 | |||
591 | /** |
||
592 | * Retrieve the lang property |
||
593 | * |
||
594 | * @return string|null |
||
595 | */ |
||
596 | public function getLang() |
||
600 | |||
601 | /** |
||
602 | * Set the lang property |
||
603 | * |
||
604 | * @param string $lang |
||
605 | * @return $this |
||
606 | */ |
||
607 | public function setLang($lang) |
||
612 | } |
||
613 |