Complex classes like HighchartsDataLabels 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 HighchartsDataLabels, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | final class HighchartsDataLabels implements JsonSerializable { |
||
26 | |||
27 | /** |
||
28 | * Align. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | private $align = "center"; |
||
33 | |||
34 | /** |
||
35 | * Allow overlap. |
||
36 | * |
||
37 | * @var boolean |
||
38 | * @since 4.1.0 |
||
39 | */ |
||
40 | private $allowOverlap = false; |
||
41 | |||
42 | /** |
||
43 | * Background color. |
||
44 | * |
||
45 | * @var string |
||
46 | * @since 2.2.1 |
||
47 | */ |
||
48 | private $backgroundColor; |
||
49 | |||
50 | /** |
||
51 | * Border color. |
||
52 | * |
||
53 | * @var string |
||
54 | * @since 2.2.1 |
||
55 | */ |
||
56 | private $borderColor; |
||
57 | |||
58 | /** |
||
59 | * Border radius. |
||
60 | * |
||
61 | * @var integer |
||
62 | * @since 2.2.1 |
||
63 | */ |
||
64 | private $borderRadius = 0; |
||
65 | |||
66 | /** |
||
67 | * Border width. |
||
68 | * |
||
69 | * @var integer |
||
70 | * @since 2.2.1 |
||
71 | */ |
||
72 | private $borderWidth = 0; |
||
73 | |||
74 | /** |
||
75 | * Class name. |
||
76 | * |
||
77 | * @var string |
||
78 | * @since 5.0.0 |
||
79 | */ |
||
80 | private $className; |
||
81 | |||
82 | /** |
||
83 | * Color. |
||
84 | * |
||
85 | * @var string |
||
86 | */ |
||
87 | private $color; |
||
88 | |||
89 | /** |
||
90 | * Crop. |
||
91 | * |
||
92 | * @var boolean |
||
93 | * @since 2.3.3 |
||
94 | */ |
||
95 | private $crop = true; |
||
96 | |||
97 | /** |
||
98 | * Defer. |
||
99 | * |
||
100 | * @var boolean |
||
101 | * @since 4.1.0 |
||
102 | */ |
||
103 | private $defer = false; |
||
104 | |||
105 | /** |
||
106 | * Enabled. |
||
107 | * |
||
108 | * @var boolean |
||
109 | * @since 4.1.0 |
||
110 | */ |
||
111 | private $enabled = true; |
||
112 | |||
113 | /** |
||
114 | * Format. |
||
115 | * |
||
116 | * @var string |
||
117 | * @since 3.0 |
||
118 | */ |
||
119 | private $format = "{y}"; |
||
120 | |||
121 | /** |
||
122 | * Formatter. |
||
123 | * |
||
124 | * @var string |
||
125 | */ |
||
126 | private $formatter; |
||
127 | |||
128 | /** |
||
129 | * Inside. |
||
130 | * |
||
131 | * @var boolean |
||
132 | * @since 4.1.0 |
||
133 | */ |
||
134 | private $inside = true; |
||
135 | |||
136 | /** |
||
137 | * Overflow. |
||
138 | * |
||
139 | * @var string |
||
140 | * @since 3.0.6 |
||
141 | */ |
||
142 | private $overflow = "justify"; |
||
143 | |||
144 | /** |
||
145 | * Padding. |
||
146 | * |
||
147 | * @var integer |
||
148 | * @since 2.2.1 |
||
149 | */ |
||
150 | private $padding = 5; |
||
151 | |||
152 | /** |
||
153 | * Rotation. |
||
154 | * |
||
155 | * @var integer |
||
156 | */ |
||
157 | private $rotation = 0; |
||
158 | |||
159 | /** |
||
160 | * Shadow. |
||
161 | * |
||
162 | * @var boolean|array |
||
163 | * @since 2.2.1 |
||
164 | */ |
||
165 | private $shadow = false; |
||
166 | |||
167 | /** |
||
168 | * Shape. |
||
169 | * |
||
170 | * @var string |
||
171 | * @since 4.1.2 |
||
172 | */ |
||
173 | private $shape = "square"; |
||
174 | |||
175 | /** |
||
176 | * Style. |
||
177 | * |
||
178 | * @var array |
||
179 | * @since 4.1.0 |
||
180 | */ |
||
181 | private $style = ["color" => "contrast", "fontSize" => "11px", "fontWeight" => "bold", "textOutline" => "1px contrast"]; |
||
182 | |||
183 | /** |
||
184 | * Use HTML. |
||
185 | * |
||
186 | * @var boolean |
||
187 | */ |
||
188 | private $useHTML = false; |
||
189 | |||
190 | /** |
||
191 | * Vertical align. |
||
192 | * |
||
193 | * @var string |
||
194 | * @since 4.1.0 |
||
195 | */ |
||
196 | private $verticalAlign = "middle"; |
||
197 | |||
198 | /** |
||
199 | * X. |
||
200 | * |
||
201 | * @var integer |
||
202 | */ |
||
203 | private $x = 0; |
||
204 | |||
205 | /** |
||
206 | * Y. |
||
207 | * |
||
208 | * @var integer |
||
209 | */ |
||
210 | private $y = -6; |
||
211 | |||
212 | /** |
||
213 | * Z index. |
||
214 | * |
||
215 | * @var integer |
||
216 | * @since 2.3.5 |
||
217 | */ |
||
218 | private $zIndex = 6; |
||
219 | |||
220 | /** |
||
221 | * Constructor. |
||
222 | * |
||
223 | * @param boolean $ignoreDefaultValues Ignore the default values. |
||
224 | */ |
||
225 | public function __construct($ignoreDefaultValues = true) { |
||
230 | |||
231 | /** |
||
232 | * Clear. |
||
233 | * |
||
234 | * @return void |
||
235 | */ |
||
236 | public function clear() { |
||
313 | |||
314 | /** |
||
315 | * Get the align. |
||
316 | * |
||
317 | * @return string Returns the align. |
||
318 | */ |
||
319 | public function getAlign() { |
||
322 | |||
323 | /** |
||
324 | * Get the allow overlap. |
||
325 | * |
||
326 | * @return boolean Returns the allow overlap. |
||
327 | */ |
||
328 | public function getAllowOverlap() { |
||
331 | |||
332 | /** |
||
333 | * Get the background color. |
||
334 | * |
||
335 | * @return string Returns the background color. |
||
336 | */ |
||
337 | public function getBackgroundColor() { |
||
340 | |||
341 | /** |
||
342 | * Get the border color. |
||
343 | * |
||
344 | * @return string Returns the border color. |
||
345 | */ |
||
346 | public function getBorderColor() { |
||
349 | |||
350 | /** |
||
351 | * Get the border radius. |
||
352 | * |
||
353 | * @return integer Returns the border radius. |
||
354 | */ |
||
355 | public function getBorderRadius() { |
||
358 | |||
359 | /** |
||
360 | * Get the border width. |
||
361 | * |
||
362 | * @return integer Returns the border width. |
||
363 | */ |
||
364 | public function getBorderWidth() { |
||
367 | |||
368 | /** |
||
369 | * Get the class name. |
||
370 | * |
||
371 | * @return string Returns the class name. |
||
372 | */ |
||
373 | public function getClassName() { |
||
376 | |||
377 | /** |
||
378 | * Get the color. |
||
379 | * |
||
380 | * @return string Returns the color. |
||
381 | */ |
||
382 | public function getColor() { |
||
385 | |||
386 | /** |
||
387 | * Get the crop. |
||
388 | * |
||
389 | * @return boolean Returns the crop. |
||
390 | */ |
||
391 | public function getCrop() { |
||
394 | |||
395 | /** |
||
396 | * Get the defer. |
||
397 | * |
||
398 | * @return boolean Returns the defer. |
||
399 | */ |
||
400 | public function getDefer() { |
||
403 | |||
404 | /** |
||
405 | * Get the enabled. |
||
406 | * |
||
407 | * @return boolean Returns the enabled. |
||
408 | */ |
||
409 | public function getEnabled() { |
||
412 | |||
413 | /** |
||
414 | * Get the format. |
||
415 | * |
||
416 | * @return string Returns the format. |
||
417 | */ |
||
418 | public function getFormat() { |
||
421 | |||
422 | /** |
||
423 | * Get the formatter. |
||
424 | * |
||
425 | * @return string Returns the formatter. |
||
426 | */ |
||
427 | public function getFormatter() { |
||
430 | |||
431 | /** |
||
432 | * Get the inside. |
||
433 | * |
||
434 | * @return boolean Returns the inside. |
||
435 | */ |
||
436 | public function getInside() { |
||
439 | |||
440 | /** |
||
441 | * Get the overflow. |
||
442 | * |
||
443 | * @return string Returns the overflow. |
||
444 | */ |
||
445 | public function getOverflow() { |
||
448 | |||
449 | /** |
||
450 | * Get the padding. |
||
451 | * |
||
452 | * @return integer Returns the padding. |
||
453 | */ |
||
454 | public function getPadding() { |
||
457 | |||
458 | /** |
||
459 | * Get the rotation. |
||
460 | * |
||
461 | * @return integer Returns the rotation. |
||
462 | */ |
||
463 | public function getRotation() { |
||
466 | |||
467 | /** |
||
468 | * Get the shadow. |
||
469 | * |
||
470 | * @return boolean|array Returns the shadow. |
||
471 | */ |
||
472 | public function getShadow() { |
||
475 | |||
476 | /** |
||
477 | * Get the shape. |
||
478 | * |
||
479 | * @return string Returns the shape. |
||
480 | */ |
||
481 | public function getShape() { |
||
484 | |||
485 | /** |
||
486 | * Get the style. |
||
487 | * |
||
488 | * @return array Returns the style. |
||
489 | */ |
||
490 | public function getStyle() { |
||
493 | |||
494 | /** |
||
495 | * Get the use HTML. |
||
496 | * |
||
497 | * @return boolean Returns the use HTML. |
||
498 | */ |
||
499 | public function getUseHTML() { |
||
502 | |||
503 | /** |
||
504 | * Get the vertical align. |
||
505 | * |
||
506 | * @return string Returns the vertical align. |
||
507 | */ |
||
508 | public function getVerticalAlign() { |
||
511 | |||
512 | /** |
||
513 | * Get the x. |
||
514 | * |
||
515 | * @return integer Returns the x. |
||
516 | */ |
||
517 | public function getX() { |
||
520 | |||
521 | /** |
||
522 | * Get the y. |
||
523 | * |
||
524 | * @return integer Returns the y. |
||
525 | */ |
||
526 | public function getY() { |
||
529 | |||
530 | /** |
||
531 | * Get the z index. |
||
532 | * |
||
533 | * @return integer Returns the z index. |
||
534 | */ |
||
535 | public function getZIndex() { |
||
538 | |||
539 | /** |
||
540 | * Serialize this instance. |
||
541 | * |
||
542 | * @return array Returns an array representing this instance. |
||
543 | */ |
||
544 | public function jsonSerialize() { |
||
547 | |||
548 | /** |
||
549 | * Set the align. |
||
550 | * |
||
551 | * @param string $align The align. |
||
552 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
553 | */ |
||
554 | public function setAlign($align) { |
||
564 | |||
565 | /** |
||
566 | * Set the allow overlap. |
||
567 | * |
||
568 | * @param boolean $allowOverlap The allow overlap. |
||
569 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
570 | */ |
||
571 | public function setAllowOverlap($allowOverlap) { |
||
575 | |||
576 | /** |
||
577 | * Set the background color. |
||
578 | * |
||
579 | * @param string $backgroundColor The background color. |
||
580 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
581 | */ |
||
582 | public function setBackgroundColor($backgroundColor) { |
||
586 | |||
587 | /** |
||
588 | * Set the border color. |
||
589 | * |
||
590 | * @param string $borderColor The border color. |
||
591 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
592 | */ |
||
593 | public function setBorderColor($borderColor) { |
||
597 | |||
598 | /** |
||
599 | * Set the border radius. |
||
600 | * |
||
601 | * @param integer $borderRadius The border radius. |
||
602 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
603 | */ |
||
604 | public function setBorderRadius($borderRadius) { |
||
608 | |||
609 | /** |
||
610 | * Set the border width. |
||
611 | * |
||
612 | * @param integer $borderWidth The border width. |
||
613 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
614 | */ |
||
615 | public function setBorderWidth($borderWidth) { |
||
619 | |||
620 | /** |
||
621 | * Set the class name. |
||
622 | * |
||
623 | * @param string $className The class name. |
||
624 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
625 | */ |
||
626 | public function setClassName($className) { |
||
630 | |||
631 | /** |
||
632 | * Set the color. |
||
633 | * |
||
634 | * @param string $color The color. |
||
635 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
636 | */ |
||
637 | public function setColor($color) { |
||
641 | |||
642 | /** |
||
643 | * Set the crop. |
||
644 | * |
||
645 | * @param boolean $crop The crop. |
||
646 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
647 | */ |
||
648 | public function setCrop($crop) { |
||
652 | |||
653 | /** |
||
654 | * Set the defer. |
||
655 | * |
||
656 | * @param boolean $defer The defer. |
||
657 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
658 | */ |
||
659 | public function setDefer($defer) { |
||
663 | |||
664 | /** |
||
665 | * Set the enabled. |
||
666 | * |
||
667 | * @param boolean $enabled The enabled. |
||
668 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
669 | */ |
||
670 | public function setEnabled($enabled) { |
||
674 | |||
675 | /** |
||
676 | * Set the format. |
||
677 | * |
||
678 | * @param string $format The format. |
||
679 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
680 | */ |
||
681 | public function setFormat($format) { |
||
685 | |||
686 | /** |
||
687 | * Set the formatter. |
||
688 | * |
||
689 | * @param string $formatter The formatter. |
||
690 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
691 | */ |
||
692 | public function setFormatter($formatter) { |
||
696 | |||
697 | /** |
||
698 | * Set the inside. |
||
699 | * |
||
700 | * @param boolean $inside The inside. |
||
701 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
702 | */ |
||
703 | public function setInside($inside) { |
||
707 | |||
708 | /** |
||
709 | * Set the overflow. |
||
710 | * |
||
711 | * @param string $overflow The overflow. |
||
712 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
713 | */ |
||
714 | public function setOverflow($overflow) { |
||
723 | |||
724 | /** |
||
725 | * Set the padding. |
||
726 | * |
||
727 | * @param integer $padding The padding. |
||
728 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
729 | */ |
||
730 | public function setPadding($padding) { |
||
734 | |||
735 | /** |
||
736 | * Set the rotation. |
||
737 | * |
||
738 | * @param integer $rotation The rotation. |
||
739 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
740 | */ |
||
741 | public function setRotation($rotation) { |
||
745 | |||
746 | /** |
||
747 | * Set the shadow. |
||
748 | * |
||
749 | * @param boolean|array $shadow The shadow. |
||
750 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
751 | */ |
||
752 | public function setShadow($shadow) { |
||
756 | |||
757 | /** |
||
758 | * Set the shape. |
||
759 | * |
||
760 | * @param string $shape The shape. |
||
761 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
762 | */ |
||
763 | public function setShape($shape) { |
||
767 | |||
768 | /** |
||
769 | * Set the style. |
||
770 | * |
||
771 | * @param array $style The style. |
||
772 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
773 | */ |
||
774 | public function setStyle(array $style = null) { |
||
778 | |||
779 | /** |
||
780 | * Set the use HTML. |
||
781 | * |
||
782 | * @param boolean $useHTML The use HTML. |
||
783 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
784 | */ |
||
785 | public function setUseHTML($useHTML) { |
||
789 | |||
790 | /** |
||
791 | * Set the vertical align. |
||
792 | * |
||
793 | * @param string $verticalAlign The vertical align. |
||
794 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
795 | */ |
||
796 | public function setVerticalAlign($verticalAlign) { |
||
800 | |||
801 | /** |
||
802 | * Set the x. |
||
803 | * |
||
804 | * @param integer $x The x. |
||
805 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
806 | */ |
||
807 | public function setX($x) { |
||
811 | |||
812 | /** |
||
813 | * Set the y. |
||
814 | * |
||
815 | * @param integer $y The y. |
||
816 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
817 | */ |
||
818 | public function setY($y) { |
||
822 | |||
823 | /** |
||
824 | * Set the z index. |
||
825 | * |
||
826 | * @param integer $zIndex The z index. |
||
827 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\Series\Treemap\HighchartsDataLabels Returns the highcharts data labels. |
||
828 | */ |
||
829 | public function setZIndex($zIndex) { |
||
833 | |||
834 | /** |
||
835 | * Convert into an array representing this instance. |
||
836 | * |
||
837 | * @return array Returns an array representing this instance. |
||
838 | */ |
||
839 | public function toArray() { |
||
922 | |||
923 | } |
||
924 |
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..