Complex classes like HighchartsLabels 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 HighchartsLabels, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | final class HighchartsLabels implements JsonSerializable { |
||
26 | |||
27 | /** |
||
28 | * Align. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $align; |
||
33 | |||
34 | /** |
||
35 | * Auto rotation. |
||
36 | * |
||
37 | * @var array |
||
38 | * @since 4.1.0 |
||
39 | */ |
||
40 | private $autoRotation = [-45]; |
||
41 | |||
42 | /** |
||
43 | * Auto rotation limit. |
||
44 | * |
||
45 | * @var integer |
||
46 | * @since 4.1.5 |
||
47 | */ |
||
48 | private $autoRotationLimit = 80; |
||
49 | |||
50 | /** |
||
51 | * Distance. |
||
52 | * |
||
53 | * @var integer |
||
54 | */ |
||
55 | private $distance = 15; |
||
56 | |||
57 | /** |
||
58 | * Enabled. |
||
59 | * |
||
60 | * @var boolean |
||
61 | */ |
||
62 | private $enabled = true; |
||
63 | |||
64 | /** |
||
65 | * Format. |
||
66 | * |
||
67 | * @var string |
||
68 | * @since 3.0 |
||
69 | */ |
||
70 | private $format = "{value}"; |
||
71 | |||
72 | /** |
||
73 | * Formatter. |
||
74 | * |
||
75 | * @var string |
||
76 | */ |
||
77 | private $formatter; |
||
78 | |||
79 | /** |
||
80 | * Overflow. |
||
81 | * |
||
82 | * @var string |
||
83 | * @since 2.2.5 |
||
84 | * @deprecated |
||
85 | */ |
||
86 | private $overflow; |
||
87 | |||
88 | /** |
||
89 | * Padding. |
||
90 | * |
||
91 | * @var integer |
||
92 | */ |
||
93 | private $padding = 5; |
||
94 | |||
95 | /** |
||
96 | * Reserve space. |
||
97 | * |
||
98 | * @var boolean |
||
99 | * @since 4.1.10 |
||
100 | */ |
||
101 | private $reserveSpace = true; |
||
102 | |||
103 | /** |
||
104 | * Rotation. |
||
105 | * |
||
106 | * @var integer |
||
107 | */ |
||
108 | private $rotation = 0; |
||
109 | |||
110 | /** |
||
111 | * Stagger lines. |
||
112 | * |
||
113 | * @var integer |
||
114 | * @since 2.1 |
||
115 | */ |
||
116 | private $staggerLines; |
||
117 | |||
118 | /** |
||
119 | * Step. |
||
120 | * |
||
121 | * @var integer |
||
122 | * @since 2.1 |
||
123 | */ |
||
124 | private $step; |
||
125 | |||
126 | /** |
||
127 | * Style. |
||
128 | * |
||
129 | * @var array |
||
130 | */ |
||
131 | private $style = ["color" => "#666666", "cursor" => "default", "fontSize" => "11px"]; |
||
132 | |||
133 | /** |
||
134 | * Use HTML. |
||
135 | * |
||
136 | * @var boolean |
||
137 | */ |
||
138 | private $useHTML = false; |
||
139 | |||
140 | /** |
||
141 | * X. |
||
142 | * |
||
143 | * @var integer |
||
144 | */ |
||
145 | private $x = 0; |
||
146 | |||
147 | /** |
||
148 | * Y. |
||
149 | * |
||
150 | * @var integer |
||
151 | */ |
||
152 | private $y; |
||
153 | |||
154 | /** |
||
155 | * Z index. |
||
156 | * |
||
157 | * @var integer |
||
158 | */ |
||
159 | private $zIndex = 7; |
||
160 | |||
161 | /** |
||
162 | * Constructor. |
||
163 | * |
||
164 | * @param boolean $ignoreDefaultValues Ignore the default values. |
||
165 | */ |
||
166 | public function __construct($ignoreDefaultValues = true) { |
||
171 | |||
172 | /** |
||
173 | * Clear. |
||
174 | * |
||
175 | * @return void |
||
176 | */ |
||
177 | public function clear() { |
||
233 | |||
234 | /** |
||
235 | * Get the align. |
||
236 | * |
||
237 | * @return string Returns the align. |
||
238 | */ |
||
239 | public function getAlign() { |
||
242 | |||
243 | /** |
||
244 | * Get the auto rotation. |
||
245 | * |
||
246 | * @return array Returns the auto rotation. |
||
247 | */ |
||
248 | public function getAutoRotation() { |
||
251 | |||
252 | /** |
||
253 | * Get the auto rotation limit. |
||
254 | * |
||
255 | * @return integer Returns the auto rotation limit. |
||
256 | */ |
||
257 | public function getAutoRotationLimit() { |
||
260 | |||
261 | /** |
||
262 | * Get the distance. |
||
263 | * |
||
264 | * @return integer Returns the distance. |
||
265 | */ |
||
266 | public function getDistance() { |
||
269 | |||
270 | /** |
||
271 | * Get the enabled. |
||
272 | * |
||
273 | * @return boolean Returns the enabled. |
||
274 | */ |
||
275 | public function getEnabled() { |
||
278 | |||
279 | /** |
||
280 | * Get the format. |
||
281 | * |
||
282 | * @return string Returns the format. |
||
283 | */ |
||
284 | public function getFormat() { |
||
287 | |||
288 | /** |
||
289 | * Get the formatter. |
||
290 | * |
||
291 | * @return string Returns the formatter. |
||
292 | */ |
||
293 | public function getFormatter() { |
||
296 | |||
297 | /** |
||
298 | * Get the overflow. |
||
299 | * |
||
300 | * @return string Returns the overflow. |
||
301 | * @deprecated |
||
302 | */ |
||
303 | public function getOverflow() { |
||
306 | |||
307 | /** |
||
308 | * Get the padding. |
||
309 | * |
||
310 | * @return integer Returns the padding. |
||
311 | */ |
||
312 | public function getPadding() { |
||
315 | |||
316 | /** |
||
317 | * Get the reserve space. |
||
318 | * |
||
319 | * @return boolean Returns the reserve space. |
||
320 | */ |
||
321 | public function getReserveSpace() { |
||
324 | |||
325 | /** |
||
326 | * Get the rotation. |
||
327 | * |
||
328 | * @return integer Returns the rotation. |
||
329 | */ |
||
330 | public function getRotation() { |
||
333 | |||
334 | /** |
||
335 | * Get the stagger lines. |
||
336 | * |
||
337 | * @return integer Returns the stagger lines. |
||
338 | */ |
||
339 | public function getStaggerLines() { |
||
342 | |||
343 | /** |
||
344 | * Get the step. |
||
345 | * |
||
346 | * @return integer Returns the step. |
||
347 | */ |
||
348 | public function getStep() { |
||
351 | |||
352 | /** |
||
353 | * Get the style. |
||
354 | * |
||
355 | * @return array Returns the style. |
||
356 | */ |
||
357 | public function getStyle() { |
||
360 | |||
361 | /** |
||
362 | * Get the use HTML. |
||
363 | * |
||
364 | * @return boolean Returns the use HTML. |
||
365 | */ |
||
366 | public function getUseHTML() { |
||
369 | |||
370 | /** |
||
371 | * Get the x. |
||
372 | * |
||
373 | * @return integer Returns the x. |
||
374 | */ |
||
375 | public function getX() { |
||
378 | |||
379 | /** |
||
380 | * Get the y. |
||
381 | * |
||
382 | * @return integer Returns the y. |
||
383 | */ |
||
384 | public function getY() { |
||
387 | |||
388 | /** |
||
389 | * Get the z index. |
||
390 | * |
||
391 | * @return integer Returns the z index. |
||
392 | */ |
||
393 | public function getZIndex() { |
||
396 | |||
397 | /** |
||
398 | * Serialize this instance. |
||
399 | * |
||
400 | * @return array Returns an array representing this instance. |
||
401 | */ |
||
402 | public function jsonSerialize() { |
||
405 | |||
406 | /** |
||
407 | * Set the align. |
||
408 | * |
||
409 | * @param string $align The align. |
||
410 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
411 | */ |
||
412 | public function setAlign($align) { |
||
422 | |||
423 | /** |
||
424 | * Set the auto rotation. |
||
425 | * |
||
426 | * @param array $autoRotation The auto rotation. |
||
427 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
428 | */ |
||
429 | public function setAutoRotation(array $autoRotation = null) { |
||
433 | |||
434 | /** |
||
435 | * Set the auto rotation limit. |
||
436 | * |
||
437 | * @param integer $autoRotationLimit The auto rotation limit. |
||
438 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
439 | */ |
||
440 | public function setAutoRotationLimit($autoRotationLimit) { |
||
444 | |||
445 | /** |
||
446 | * Set the distance. |
||
447 | * |
||
448 | * @param integer $distance The distance. |
||
449 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
450 | */ |
||
451 | public function setDistance($distance) { |
||
455 | |||
456 | /** |
||
457 | * Set the enabled. |
||
458 | * |
||
459 | * @param boolean $enabled The enabled. |
||
460 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
461 | */ |
||
462 | public function setEnabled($enabled) { |
||
466 | |||
467 | /** |
||
468 | * Set the format. |
||
469 | * |
||
470 | * @param string $format The format. |
||
471 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
472 | */ |
||
473 | public function setFormat($format) { |
||
477 | |||
478 | /** |
||
479 | * Set the formatter. |
||
480 | * |
||
481 | * @param string $formatter The formatter. |
||
482 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
483 | */ |
||
484 | public function setFormatter($formatter) { |
||
488 | |||
489 | /** |
||
490 | * Set the overflow. |
||
491 | * |
||
492 | * @param string $overflow The overflow. |
||
493 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
494 | * @deprecated |
||
495 | */ |
||
496 | public function setOverflow($overflow) { |
||
505 | |||
506 | /** |
||
507 | * Set the padding. |
||
508 | * |
||
509 | * @param integer $padding The padding. |
||
510 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
511 | */ |
||
512 | public function setPadding($padding) { |
||
516 | |||
517 | /** |
||
518 | * Set the reserve space. |
||
519 | * |
||
520 | * @param boolean $reserveSpace The reserve space. |
||
521 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
522 | */ |
||
523 | public function setReserveSpace($reserveSpace) { |
||
527 | |||
528 | /** |
||
529 | * Set the rotation. |
||
530 | * |
||
531 | * @param integer $rotation The rotation. |
||
532 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
533 | */ |
||
534 | public function setRotation($rotation) { |
||
538 | |||
539 | /** |
||
540 | * Set the stagger lines. |
||
541 | * |
||
542 | * @param integer $staggerLines The stagger lines. |
||
543 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
544 | */ |
||
545 | public function setStaggerLines($staggerLines) { |
||
549 | |||
550 | /** |
||
551 | * Set the step. |
||
552 | * |
||
553 | * @param integer $step The step. |
||
554 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
555 | */ |
||
556 | public function setStep($step) { |
||
560 | |||
561 | /** |
||
562 | * Set the style. |
||
563 | * |
||
564 | * @param array $style The style. |
||
565 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
566 | */ |
||
567 | public function setStyle(array $style = null) { |
||
571 | |||
572 | /** |
||
573 | * Set the use HTML. |
||
574 | * |
||
575 | * @param boolean $useHTML The use HTML. |
||
576 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
577 | */ |
||
578 | public function setUseHTML($useHTML) { |
||
582 | |||
583 | /** |
||
584 | * Set the x. |
||
585 | * |
||
586 | * @param integer $x The x. |
||
587 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
588 | */ |
||
589 | public function setX($x) { |
||
593 | |||
594 | /** |
||
595 | * Set the y. |
||
596 | * |
||
597 | * @param integer $y The y. |
||
598 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
599 | */ |
||
600 | public function setY($y) { |
||
604 | |||
605 | /** |
||
606 | * Set the z index. |
||
607 | * |
||
608 | * @param integer $zIndex The z index. |
||
609 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\XAxis\HighchartsLabels Returns the highcharts labels. |
||
610 | */ |
||
611 | public function setZIndex($zIndex) { |
||
615 | |||
616 | /** |
||
617 | * Convert into an array representing this instance. |
||
618 | * |
||
619 | * @return array Returns an array representing this instance. |
||
620 | */ |
||
621 | public function toArray() { |
||
683 | |||
684 | } |
||
685 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..