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.0 |
||
102 | */ |
||
103 | private $defer = true; |
||
104 | |||
105 | /** |
||
106 | * Enabled. |
||
107 | * |
||
108 | * @var boolean |
||
109 | */ |
||
110 | private $enabled = false; |
||
111 | |||
112 | /** |
||
113 | * Format. |
||
114 | * |
||
115 | * @var string |
||
116 | * @since 3.0 |
||
117 | */ |
||
118 | private $format = "{y}"; |
||
119 | |||
120 | /** |
||
121 | * Formatter. |
||
122 | * |
||
123 | * @var string |
||
124 | */ |
||
125 | private $formatter; |
||
126 | |||
127 | /** |
||
128 | * Inside. |
||
129 | * |
||
130 | * @var boolean |
||
131 | * @since 3.0 |
||
132 | */ |
||
133 | private $inside; |
||
134 | |||
135 | /** |
||
136 | * Overflow. |
||
137 | * |
||
138 | * @var string |
||
139 | * @since 3.0.6 |
||
140 | */ |
||
141 | private $overflow = "justify"; |
||
142 | |||
143 | /** |
||
144 | * Padding. |
||
145 | * |
||
146 | * @var integer |
||
147 | * @since 2.2.1 |
||
148 | */ |
||
149 | private $padding = 5; |
||
150 | |||
151 | /** |
||
152 | * Rotation. |
||
153 | * |
||
154 | * @var integer |
||
155 | */ |
||
156 | private $rotation = 0; |
||
157 | |||
158 | /** |
||
159 | * Shadow. |
||
160 | * |
||
161 | * @var boolean|array |
||
162 | * @since 2.2.1 |
||
163 | */ |
||
164 | private $shadow = false; |
||
165 | |||
166 | /** |
||
167 | * Shape. |
||
168 | * |
||
169 | * @var string |
||
170 | * @since 4.1.2 |
||
171 | */ |
||
172 | private $shape = "square"; |
||
173 | |||
174 | /** |
||
175 | * Style. |
||
176 | * |
||
177 | * @var array |
||
178 | * @since 4.1.0 |
||
179 | */ |
||
180 | private $style = ["color" => "contrast", "fontSize" => "11px", "fontWeight" => "bold", "textOutline" => "1px contrast"]; |
||
181 | |||
182 | /** |
||
183 | * Use HTML. |
||
184 | * |
||
185 | * @var boolean |
||
186 | */ |
||
187 | private $useHTML = false; |
||
188 | |||
189 | /** |
||
190 | * Vertical align. |
||
191 | * |
||
192 | * @var string |
||
193 | * @since 2.3.3 |
||
194 | */ |
||
195 | private $verticalAlign; |
||
196 | |||
197 | /** |
||
198 | * X high. |
||
199 | * |
||
200 | * @var integer |
||
201 | * @since 2.3.0 |
||
202 | */ |
||
203 | private $xHigh = 0; |
||
204 | |||
205 | /** |
||
206 | * X low. |
||
207 | * |
||
208 | * @var integer |
||
209 | * @since 2.3.0 |
||
210 | */ |
||
211 | private $xLow = 0; |
||
212 | |||
213 | /** |
||
214 | * Y high. |
||
215 | * |
||
216 | * @var integer |
||
217 | * @since 2.3.0 |
||
218 | */ |
||
219 | private $yHigh = -6; |
||
220 | |||
221 | /** |
||
222 | * Y low. |
||
223 | * |
||
224 | * @var integer |
||
225 | * @since 2.3.0 |
||
226 | */ |
||
227 | private $yLow = 16; |
||
228 | |||
229 | /** |
||
230 | * Z index. |
||
231 | * |
||
232 | * @var integer |
||
233 | * @since 2.3.5 |
||
234 | */ |
||
235 | private $zIndex = 6; |
||
236 | |||
237 | /** |
||
238 | * Constructor. |
||
239 | * |
||
240 | * @param boolean $ignoreDefaultValues Ignore the default values. |
||
241 | */ |
||
242 | public function __construct($ignoreDefaultValues = true) { |
||
247 | |||
248 | /** |
||
249 | * Clear. |
||
250 | * |
||
251 | * @return void |
||
252 | */ |
||
253 | public function clear() { |
||
336 | |||
337 | /** |
||
338 | * Get the align. |
||
339 | * |
||
340 | * @return string Returns the align. |
||
341 | */ |
||
342 | public function getAlign() { |
||
345 | |||
346 | /** |
||
347 | * Get the allow overlap. |
||
348 | * |
||
349 | * @return boolean Returns the allow overlap. |
||
350 | */ |
||
351 | public function getAllowOverlap() { |
||
354 | |||
355 | /** |
||
356 | * Get the background color. |
||
357 | * |
||
358 | * @return string Returns the background color. |
||
359 | */ |
||
360 | public function getBackgroundColor() { |
||
363 | |||
364 | /** |
||
365 | * Get the border color. |
||
366 | * |
||
367 | * @return string Returns the border color. |
||
368 | */ |
||
369 | public function getBorderColor() { |
||
372 | |||
373 | /** |
||
374 | * Get the border radius. |
||
375 | * |
||
376 | * @return integer Returns the border radius. |
||
377 | */ |
||
378 | public function getBorderRadius() { |
||
381 | |||
382 | /** |
||
383 | * Get the border width. |
||
384 | * |
||
385 | * @return integer Returns the border width. |
||
386 | */ |
||
387 | public function getBorderWidth() { |
||
390 | |||
391 | /** |
||
392 | * Get the class name. |
||
393 | * |
||
394 | * @return string Returns the class name. |
||
395 | */ |
||
396 | public function getClassName() { |
||
399 | |||
400 | /** |
||
401 | * Get the color. |
||
402 | * |
||
403 | * @return string Returns the color. |
||
404 | */ |
||
405 | public function getColor() { |
||
408 | |||
409 | /** |
||
410 | * Get the crop. |
||
411 | * |
||
412 | * @return boolean Returns the crop. |
||
413 | */ |
||
414 | public function getCrop() { |
||
417 | |||
418 | /** |
||
419 | * Get the defer. |
||
420 | * |
||
421 | * @return boolean Returns the defer. |
||
422 | */ |
||
423 | public function getDefer() { |
||
426 | |||
427 | /** |
||
428 | * Get the enabled. |
||
429 | * |
||
430 | * @return boolean Returns the enabled. |
||
431 | */ |
||
432 | public function getEnabled() { |
||
435 | |||
436 | /** |
||
437 | * Get the format. |
||
438 | * |
||
439 | * @return string Returns the format. |
||
440 | */ |
||
441 | public function getFormat() { |
||
444 | |||
445 | /** |
||
446 | * Get the formatter. |
||
447 | * |
||
448 | * @return string Returns the formatter. |
||
449 | */ |
||
450 | public function getFormatter() { |
||
453 | |||
454 | /** |
||
455 | * Get the inside. |
||
456 | * |
||
457 | * @return boolean Returns the inside. |
||
458 | */ |
||
459 | public function getInside() { |
||
462 | |||
463 | /** |
||
464 | * Get the overflow. |
||
465 | * |
||
466 | * @return string Returns the overflow. |
||
467 | */ |
||
468 | public function getOverflow() { |
||
471 | |||
472 | /** |
||
473 | * Get the padding. |
||
474 | * |
||
475 | * @return integer Returns the padding. |
||
476 | */ |
||
477 | public function getPadding() { |
||
480 | |||
481 | /** |
||
482 | * Get the rotation. |
||
483 | * |
||
484 | * @return integer Returns the rotation. |
||
485 | */ |
||
486 | public function getRotation() { |
||
489 | |||
490 | /** |
||
491 | * Get the shadow. |
||
492 | * |
||
493 | * @return boolean|array Returns the shadow. |
||
494 | */ |
||
495 | public function getShadow() { |
||
498 | |||
499 | /** |
||
500 | * Get the shape. |
||
501 | * |
||
502 | * @return string Returns the shape. |
||
503 | */ |
||
504 | public function getShape() { |
||
507 | |||
508 | /** |
||
509 | * Get the style. |
||
510 | * |
||
511 | * @return array Returns the style. |
||
512 | */ |
||
513 | public function getStyle() { |
||
516 | |||
517 | /** |
||
518 | * Get the use HTML. |
||
519 | * |
||
520 | * @return boolean Returns the use HTML. |
||
521 | */ |
||
522 | public function getUseHTML() { |
||
525 | |||
526 | /** |
||
527 | * Get the vertical align. |
||
528 | * |
||
529 | * @return string Returns the vertical align. |
||
530 | */ |
||
531 | public function getVerticalAlign() { |
||
534 | |||
535 | /** |
||
536 | * Get the x high. |
||
537 | * |
||
538 | * @return integer Returns the x high. |
||
539 | */ |
||
540 | public function getXHigh() { |
||
543 | |||
544 | /** |
||
545 | * Get the x low. |
||
546 | * |
||
547 | * @return integer Returns the x low. |
||
548 | */ |
||
549 | public function getXLow() { |
||
552 | |||
553 | /** |
||
554 | * Get the y high. |
||
555 | * |
||
556 | * @return integer Returns the y high. |
||
557 | */ |
||
558 | public function getYHigh() { |
||
561 | |||
562 | /** |
||
563 | * Get the y low. |
||
564 | * |
||
565 | * @return integer Returns the y low. |
||
566 | */ |
||
567 | public function getYLow() { |
||
570 | |||
571 | /** |
||
572 | * Get the z index. |
||
573 | * |
||
574 | * @return integer Returns the z index. |
||
575 | */ |
||
576 | public function getZIndex() { |
||
579 | |||
580 | /** |
||
581 | * Serialize this instance. |
||
582 | * |
||
583 | * @return array Returns an array representing this instance. |
||
584 | */ |
||
585 | public function jsonSerialize() { |
||
588 | |||
589 | /** |
||
590 | * Set the align. |
||
591 | * |
||
592 | * @param string $align The align. |
||
593 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
594 | */ |
||
595 | public function setAlign($align) { |
||
605 | |||
606 | /** |
||
607 | * Set the allow overlap. |
||
608 | * |
||
609 | * @param boolean $allowOverlap The allow overlap. |
||
610 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
611 | */ |
||
612 | public function setAllowOverlap($allowOverlap) { |
||
616 | |||
617 | /** |
||
618 | * Set the background color. |
||
619 | * |
||
620 | * @param string $backgroundColor The background color. |
||
621 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
622 | */ |
||
623 | public function setBackgroundColor($backgroundColor) { |
||
627 | |||
628 | /** |
||
629 | * Set the border color. |
||
630 | * |
||
631 | * @param string $borderColor The border color. |
||
632 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
633 | */ |
||
634 | public function setBorderColor($borderColor) { |
||
638 | |||
639 | /** |
||
640 | * Set the border radius. |
||
641 | * |
||
642 | * @param integer $borderRadius The border radius. |
||
643 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
644 | */ |
||
645 | public function setBorderRadius($borderRadius) { |
||
649 | |||
650 | /** |
||
651 | * Set the border width. |
||
652 | * |
||
653 | * @param integer $borderWidth The border width. |
||
654 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
655 | */ |
||
656 | public function setBorderWidth($borderWidth) { |
||
660 | |||
661 | /** |
||
662 | * Set the class name. |
||
663 | * |
||
664 | * @param string $className The class name. |
||
665 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
666 | */ |
||
667 | public function setClassName($className) { |
||
671 | |||
672 | /** |
||
673 | * Set the color. |
||
674 | * |
||
675 | * @param string $color The color. |
||
676 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
677 | */ |
||
678 | public function setColor($color) { |
||
682 | |||
683 | /** |
||
684 | * Set the crop. |
||
685 | * |
||
686 | * @param boolean $crop The crop. |
||
687 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
688 | */ |
||
689 | public function setCrop($crop) { |
||
693 | |||
694 | /** |
||
695 | * Set the defer. |
||
696 | * |
||
697 | * @param boolean $defer The defer. |
||
698 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
699 | */ |
||
700 | public function setDefer($defer) { |
||
704 | |||
705 | /** |
||
706 | * Set the enabled. |
||
707 | * |
||
708 | * @param boolean $enabled The enabled. |
||
709 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
710 | */ |
||
711 | public function setEnabled($enabled) { |
||
715 | |||
716 | /** |
||
717 | * Set the format. |
||
718 | * |
||
719 | * @param string $format The format. |
||
720 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
721 | */ |
||
722 | public function setFormat($format) { |
||
726 | |||
727 | /** |
||
728 | * Set the formatter. |
||
729 | * |
||
730 | * @param string $formatter The formatter. |
||
731 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
732 | */ |
||
733 | public function setFormatter($formatter) { |
||
737 | |||
738 | /** |
||
739 | * Set the inside. |
||
740 | * |
||
741 | * @param boolean $inside The inside. |
||
742 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
743 | */ |
||
744 | public function setInside($inside) { |
||
748 | |||
749 | /** |
||
750 | * Set the overflow. |
||
751 | * |
||
752 | * @param string $overflow The overflow. |
||
753 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
754 | */ |
||
755 | public function setOverflow($overflow) { |
||
764 | |||
765 | /** |
||
766 | * Set the padding. |
||
767 | * |
||
768 | * @param integer $padding The padding. |
||
769 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
770 | */ |
||
771 | public function setPadding($padding) { |
||
775 | |||
776 | /** |
||
777 | * Set the rotation. |
||
778 | * |
||
779 | * @param integer $rotation The rotation. |
||
780 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
781 | */ |
||
782 | public function setRotation($rotation) { |
||
786 | |||
787 | /** |
||
788 | * Set the shadow. |
||
789 | * |
||
790 | * @param boolean|array $shadow The shadow. |
||
791 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
792 | */ |
||
793 | public function setShadow($shadow) { |
||
797 | |||
798 | /** |
||
799 | * Set the shape. |
||
800 | * |
||
801 | * @param string $shape The shape. |
||
802 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
803 | */ |
||
804 | public function setShape($shape) { |
||
808 | |||
809 | /** |
||
810 | * Set the style. |
||
811 | * |
||
812 | * @param array $style The style. |
||
813 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
814 | */ |
||
815 | public function setStyle(array $style = null) { |
||
819 | |||
820 | /** |
||
821 | * Set the use HTML. |
||
822 | * |
||
823 | * @param boolean $useHTML The use HTML. |
||
824 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
825 | */ |
||
826 | public function setUseHTML($useHTML) { |
||
830 | |||
831 | /** |
||
832 | * Set the vertical align. |
||
833 | * |
||
834 | * @param string $verticalAlign The vertical align. |
||
835 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
836 | */ |
||
837 | public function setVerticalAlign($verticalAlign) { |
||
847 | |||
848 | /** |
||
849 | * Set the x high. |
||
850 | * |
||
851 | * @param integer $xHigh The x high. |
||
852 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
853 | */ |
||
854 | public function setXHigh($xHigh) { |
||
858 | |||
859 | /** |
||
860 | * Set the x low. |
||
861 | * |
||
862 | * @param integer $xLow The x low. |
||
863 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
864 | */ |
||
865 | public function setXLow($xLow) { |
||
869 | |||
870 | /** |
||
871 | * Set the y high. |
||
872 | * |
||
873 | * @param integer $yHigh The y high. |
||
874 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
875 | */ |
||
876 | public function setYHigh($yHigh) { |
||
880 | |||
881 | /** |
||
882 | * Set the y low. |
||
883 | * |
||
884 | * @param integer $yLow The y low. |
||
885 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
886 | */ |
||
887 | public function setYLow($yLow) { |
||
891 | |||
892 | /** |
||
893 | * Set the z index. |
||
894 | * |
||
895 | * @param integer $zIndex The z index. |
||
896 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\PlotOptions\Arearange\HighchartsDataLabels Returns the highcharts data labels. |
||
897 | */ |
||
898 | public function setZIndex($zIndex) { |
||
902 | |||
903 | /** |
||
904 | * Convert into an array representing this instance. |
||
905 | * |
||
906 | * @return array Returns an array representing this instance. |
||
907 | */ |
||
908 | public function toArray() { |
||
997 | |||
998 | } |
||
999 |
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..