Complex classes like HighchartsTooltip 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 HighchartsTooltip, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | final class HighchartsTooltip implements JsonSerializable { |
||
26 | |||
27 | /** |
||
28 | * Animation. |
||
29 | * |
||
30 | * @var boolean |
||
31 | * @since 2.3.0 |
||
32 | */ |
||
33 | private $animation = true; |
||
34 | |||
35 | /** |
||
36 | * Background color. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | private $backgroundColor = "rgba(247,247,247,0.85)"; |
||
41 | |||
42 | /** |
||
43 | * Border color. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | private $borderColor; |
||
48 | |||
49 | /** |
||
50 | * Border radius. |
||
51 | * |
||
52 | * @var integer |
||
53 | */ |
||
54 | private $borderRadius = 3; |
||
55 | |||
56 | /** |
||
57 | * Border width. |
||
58 | * |
||
59 | * @var integer |
||
60 | */ |
||
61 | private $borderWidth = 1; |
||
62 | |||
63 | /** |
||
64 | * Crosshairs. |
||
65 | * |
||
66 | * @var mixed |
||
67 | * @deprecated |
||
68 | */ |
||
69 | private $crosshairs; |
||
70 | |||
71 | /** |
||
72 | * Date time label formats. |
||
73 | * |
||
74 | * @var array |
||
75 | */ |
||
76 | private $dateTimeLabelFormats; |
||
77 | |||
78 | /** |
||
79 | * Enabled. |
||
80 | * |
||
81 | * @var boolean |
||
82 | */ |
||
83 | private $enabled = true; |
||
84 | |||
85 | /** |
||
86 | * Follow pointer. |
||
87 | * |
||
88 | * @var boolean |
||
89 | * @since 3.0 |
||
90 | */ |
||
91 | private $followPointer = false; |
||
92 | |||
93 | /** |
||
94 | * Follow touch move. |
||
95 | * |
||
96 | * @var boolean |
||
97 | * @since 3.0.1 |
||
98 | */ |
||
99 | private $followTouchMove = true; |
||
100 | |||
101 | /** |
||
102 | * Footer format. |
||
103 | * |
||
104 | * @var string |
||
105 | * @since 2.2 |
||
106 | */ |
||
107 | private $footerFormat = "false"; |
||
108 | |||
109 | /** |
||
110 | * Formatter. |
||
111 | * |
||
112 | * @var string |
||
113 | */ |
||
114 | private $formatter; |
||
115 | |||
116 | /** |
||
117 | * Header format. |
||
118 | * |
||
119 | * @var string |
||
120 | */ |
||
121 | private $headerFormat; |
||
122 | |||
123 | /** |
||
124 | * Hide delay. |
||
125 | * |
||
126 | * @var integer |
||
127 | * @since 3.0 |
||
128 | */ |
||
129 | private $hideDelay = 500; |
||
130 | |||
131 | /** |
||
132 | * Padding. |
||
133 | * |
||
134 | * @var integer |
||
135 | * @since 5.0.0 |
||
136 | */ |
||
137 | private $padding = 8; |
||
138 | |||
139 | /** |
||
140 | * Point format. |
||
141 | * |
||
142 | * @var string |
||
143 | * @since 2.2 |
||
144 | */ |
||
145 | private $pointFormat = "<span style=\"color:{point.color}\">\\u25CF</span> {series.name}: <b>{point.y}</b><br/>"; |
||
146 | |||
147 | /** |
||
148 | * Point formatter. |
||
149 | * |
||
150 | * @var string |
||
151 | * @since 4.1.0 |
||
152 | */ |
||
153 | private $pointFormatter; |
||
154 | |||
155 | /** |
||
156 | * Positioner. |
||
157 | * |
||
158 | * @var string |
||
159 | * @since 2.2.4 |
||
160 | */ |
||
161 | private $positioner; |
||
162 | |||
163 | /** |
||
164 | * Shadow. |
||
165 | * |
||
166 | * @var boolean |
||
167 | */ |
||
168 | private $shadow = true; |
||
169 | |||
170 | /** |
||
171 | * Shape. |
||
172 | * |
||
173 | * @var string |
||
174 | * @since 4.0 |
||
175 | */ |
||
176 | private $shape = "callout"; |
||
177 | |||
178 | /** |
||
179 | * Shared. |
||
180 | * |
||
181 | * @var boolean |
||
182 | * @since 2.1 |
||
183 | */ |
||
184 | private $shared = false; |
||
185 | |||
186 | /** |
||
187 | * Snap. |
||
188 | * |
||
189 | * @var integer |
||
190 | * @since 1.2.0 |
||
191 | */ |
||
192 | private $snap; |
||
193 | |||
194 | /** |
||
195 | * Split. |
||
196 | * |
||
197 | * @var boolean |
||
198 | * @since 5.0.0 |
||
199 | */ |
||
200 | private $split = false; |
||
201 | |||
202 | /** |
||
203 | * Style. |
||
204 | * |
||
205 | * @var array |
||
206 | */ |
||
207 | private $style = ["color" => "#333333", "cursor" => "default", "fontSize" => "12px", "pointerEvents" => "none", "whiteSpace" => "nowrap"]; |
||
208 | |||
209 | /** |
||
210 | * Use HTML. |
||
211 | * |
||
212 | * @var boolean |
||
213 | * @since 2.2 |
||
214 | */ |
||
215 | private $useHTML = false; |
||
216 | |||
217 | /** |
||
218 | * Value decimals. |
||
219 | * |
||
220 | * @var integer |
||
221 | * @since 2.2 |
||
222 | */ |
||
223 | private $valueDecimals; |
||
224 | |||
225 | /** |
||
226 | * Value prefix. |
||
227 | * |
||
228 | * @var string |
||
229 | * @since 2.2 |
||
230 | */ |
||
231 | private $valuePrefix; |
||
232 | |||
233 | /** |
||
234 | * Value suffix. |
||
235 | * |
||
236 | * @var string |
||
237 | * @since 2.2 |
||
238 | */ |
||
239 | private $valueSuffix; |
||
240 | |||
241 | /** |
||
242 | * X date format. |
||
243 | * |
||
244 | * @var string |
||
245 | */ |
||
246 | private $xDateFormat; |
||
247 | |||
248 | /** |
||
249 | * Constructor. |
||
250 | * |
||
251 | * @param boolean $ignoreDefaultValues Ignore the default values. |
||
252 | */ |
||
253 | public function __construct($ignoreDefaultValues = true) { |
||
258 | |||
259 | /** |
||
260 | * Clear. |
||
261 | * |
||
262 | * @return void |
||
263 | */ |
||
264 | public function clear() { |
||
353 | |||
354 | /** |
||
355 | * Get the animation. |
||
356 | * |
||
357 | * @return boolean Returns the animation. |
||
358 | */ |
||
359 | public function getAnimation() { |
||
362 | |||
363 | /** |
||
364 | * Get the background color. |
||
365 | * |
||
366 | * @return string Returns the background color. |
||
367 | */ |
||
368 | public function getBackgroundColor() { |
||
371 | |||
372 | /** |
||
373 | * Get the border color. |
||
374 | * |
||
375 | * @return string Returns the border color. |
||
376 | */ |
||
377 | public function getBorderColor() { |
||
380 | |||
381 | /** |
||
382 | * Get the border radius. |
||
383 | * |
||
384 | * @return integer Returns the border radius. |
||
385 | */ |
||
386 | public function getBorderRadius() { |
||
389 | |||
390 | /** |
||
391 | * Get the border width. |
||
392 | * |
||
393 | * @return integer Returns the border width. |
||
394 | */ |
||
395 | public function getBorderWidth() { |
||
398 | |||
399 | /** |
||
400 | * Get the crosshairs. |
||
401 | * |
||
402 | * @return mixed Returns the crosshairs. |
||
403 | * @deprecated |
||
404 | */ |
||
405 | public function getCrosshairs() { |
||
408 | |||
409 | /** |
||
410 | * Get the date time label formats. |
||
411 | * |
||
412 | * @return array Returns the date time label formats. |
||
413 | */ |
||
414 | public function getDateTimeLabelFormats() { |
||
417 | |||
418 | /** |
||
419 | * Get the enabled. |
||
420 | * |
||
421 | * @return boolean Returns the enabled. |
||
422 | */ |
||
423 | public function getEnabled() { |
||
426 | |||
427 | /** |
||
428 | * Get the follow pointer. |
||
429 | * |
||
430 | * @return boolean Returns the follow pointer. |
||
431 | */ |
||
432 | public function getFollowPointer() { |
||
435 | |||
436 | /** |
||
437 | * Get the follow touch move. |
||
438 | * |
||
439 | * @return boolean Returns the follow touch move. |
||
440 | */ |
||
441 | public function getFollowTouchMove() { |
||
444 | |||
445 | /** |
||
446 | * Get the footer format. |
||
447 | * |
||
448 | * @return string Returns the footer format. |
||
449 | */ |
||
450 | public function getFooterFormat() { |
||
453 | |||
454 | /** |
||
455 | * Get the formatter. |
||
456 | * |
||
457 | * @return string Returns the formatter. |
||
458 | */ |
||
459 | public function getFormatter() { |
||
462 | |||
463 | /** |
||
464 | * Get the header format. |
||
465 | * |
||
466 | * @return string Returns the header format. |
||
467 | */ |
||
468 | public function getHeaderFormat() { |
||
471 | |||
472 | /** |
||
473 | * Get the hide delay. |
||
474 | * |
||
475 | * @return integer Returns the hide delay. |
||
476 | */ |
||
477 | public function getHideDelay() { |
||
480 | |||
481 | /** |
||
482 | * Get the padding. |
||
483 | * |
||
484 | * @return integer Returns the padding. |
||
485 | */ |
||
486 | public function getPadding() { |
||
489 | |||
490 | /** |
||
491 | * Get the point format. |
||
492 | * |
||
493 | * @return string Returns the point format. |
||
494 | */ |
||
495 | public function getPointFormat() { |
||
498 | |||
499 | /** |
||
500 | * Get the point formatter. |
||
501 | * |
||
502 | * @return string Returns the point formatter. |
||
503 | */ |
||
504 | public function getPointFormatter() { |
||
507 | |||
508 | /** |
||
509 | * Get the positioner. |
||
510 | * |
||
511 | * @return string Returns the positioner. |
||
512 | */ |
||
513 | public function getPositioner() { |
||
516 | |||
517 | /** |
||
518 | * Get the shadow. |
||
519 | * |
||
520 | * @return boolean Returns the shadow. |
||
521 | */ |
||
522 | public function getShadow() { |
||
525 | |||
526 | /** |
||
527 | * Get the shape. |
||
528 | * |
||
529 | * @return string Returns the shape. |
||
530 | */ |
||
531 | public function getShape() { |
||
534 | |||
535 | /** |
||
536 | * Get the shared. |
||
537 | * |
||
538 | * @return boolean Returns the shared. |
||
539 | */ |
||
540 | public function getShared() { |
||
543 | |||
544 | /** |
||
545 | * Get the snap. |
||
546 | * |
||
547 | * @return integer Returns the snap. |
||
548 | */ |
||
549 | public function getSnap() { |
||
552 | |||
553 | /** |
||
554 | * Get the split. |
||
555 | * |
||
556 | * @return boolean Returns the split. |
||
557 | */ |
||
558 | public function getSplit() { |
||
561 | |||
562 | /** |
||
563 | * Get the style. |
||
564 | * |
||
565 | * @return array Returns the style. |
||
566 | */ |
||
567 | public function getStyle() { |
||
570 | |||
571 | /** |
||
572 | * Get the use HTML. |
||
573 | * |
||
574 | * @return boolean Returns the use HTML. |
||
575 | */ |
||
576 | public function getUseHTML() { |
||
579 | |||
580 | /** |
||
581 | * Get the value decimals. |
||
582 | * |
||
583 | * @return integer Returns the value decimals. |
||
584 | */ |
||
585 | public function getValueDecimals() { |
||
588 | |||
589 | /** |
||
590 | * Get the value prefix. |
||
591 | * |
||
592 | * @return string Returns the value prefix. |
||
593 | */ |
||
594 | public function getValuePrefix() { |
||
597 | |||
598 | /** |
||
599 | * Get the value suffix. |
||
600 | * |
||
601 | * @return string Returns the value suffix. |
||
602 | */ |
||
603 | public function getValueSuffix() { |
||
606 | |||
607 | /** |
||
608 | * Get the x date format. |
||
609 | * |
||
610 | * @return string Returns the x date format. |
||
611 | */ |
||
612 | public function getXDateFormat() { |
||
615 | |||
616 | /** |
||
617 | * Serialize this instance. |
||
618 | * |
||
619 | * @return array Returns an array representing this instance. |
||
620 | */ |
||
621 | public function jsonSerialize() { |
||
624 | |||
625 | /** |
||
626 | * Set the animation. |
||
627 | * |
||
628 | * @param boolean $animation The animation. |
||
629 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
630 | */ |
||
631 | public function setAnimation($animation) { |
||
635 | |||
636 | /** |
||
637 | * Set the background color. |
||
638 | * |
||
639 | * @param string $backgroundColor The background color. |
||
640 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
641 | */ |
||
642 | public function setBackgroundColor($backgroundColor) { |
||
646 | |||
647 | /** |
||
648 | * Set the border color. |
||
649 | * |
||
650 | * @param string $borderColor The border color. |
||
651 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
652 | */ |
||
653 | public function setBorderColor($borderColor) { |
||
657 | |||
658 | /** |
||
659 | * Set the border radius. |
||
660 | * |
||
661 | * @param integer $borderRadius The border radius. |
||
662 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
663 | */ |
||
664 | public function setBorderRadius($borderRadius) { |
||
668 | |||
669 | /** |
||
670 | * Set the border width. |
||
671 | * |
||
672 | * @param integer $borderWidth The border width. |
||
673 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
674 | */ |
||
675 | public function setBorderWidth($borderWidth) { |
||
679 | |||
680 | /** |
||
681 | * Set the crosshairs. |
||
682 | * |
||
683 | * @param mixed $crosshairs The crosshairs. |
||
684 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
685 | * @deprecated |
||
686 | */ |
||
687 | public function setCrosshairs($crosshairs) { |
||
691 | |||
692 | /** |
||
693 | * Set the date time label formats. |
||
694 | * |
||
695 | * @param array $dateTimeLabelFormats The date time label formats. |
||
696 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
697 | */ |
||
698 | public function setDateTimeLabelFormats(array $dateTimeLabelFormats = null) { |
||
702 | |||
703 | /** |
||
704 | * Set the enabled. |
||
705 | * |
||
706 | * @param boolean $enabled The enabled. |
||
707 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
708 | */ |
||
709 | public function setEnabled($enabled) { |
||
713 | |||
714 | /** |
||
715 | * Set the follow pointer. |
||
716 | * |
||
717 | * @param boolean $followPointer The follow pointer. |
||
718 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
719 | */ |
||
720 | public function setFollowPointer($followPointer) { |
||
724 | |||
725 | /** |
||
726 | * Set the follow touch move. |
||
727 | * |
||
728 | * @param boolean $followTouchMove The follow touch move. |
||
729 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
730 | */ |
||
731 | public function setFollowTouchMove($followTouchMove) { |
||
735 | |||
736 | /** |
||
737 | * Set the footer format. |
||
738 | * |
||
739 | * @param string $footerFormat The footer format. |
||
740 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
741 | */ |
||
742 | public function setFooterFormat($footerFormat) { |
||
746 | |||
747 | /** |
||
748 | * Set the formatter. |
||
749 | * |
||
750 | * @param string $formatter The formatter. |
||
751 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
752 | */ |
||
753 | public function setFormatter($formatter) { |
||
757 | |||
758 | /** |
||
759 | * Set the header format. |
||
760 | * |
||
761 | * @param string $headerFormat The header format. |
||
762 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
763 | */ |
||
764 | public function setHeaderFormat($headerFormat) { |
||
768 | |||
769 | /** |
||
770 | * Set the hide delay. |
||
771 | * |
||
772 | * @param integer $hideDelay The hide delay. |
||
773 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
774 | */ |
||
775 | public function setHideDelay($hideDelay) { |
||
779 | |||
780 | /** |
||
781 | * Set the padding. |
||
782 | * |
||
783 | * @param integer $padding The padding. |
||
784 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
785 | */ |
||
786 | public function setPadding($padding) { |
||
790 | |||
791 | /** |
||
792 | * Set the point format. |
||
793 | * |
||
794 | * @param string $pointFormat The point format. |
||
795 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
796 | */ |
||
797 | public function setPointFormat($pointFormat) { |
||
801 | |||
802 | /** |
||
803 | * Set the point formatter. |
||
804 | * |
||
805 | * @param string $pointFormatter The point formatter. |
||
806 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
807 | */ |
||
808 | public function setPointFormatter($pointFormatter) { |
||
812 | |||
813 | /** |
||
814 | * Set the positioner. |
||
815 | * |
||
816 | * @param string $positioner The positioner. |
||
817 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
818 | */ |
||
819 | public function setPositioner($positioner) { |
||
823 | |||
824 | /** |
||
825 | * Set the shadow. |
||
826 | * |
||
827 | * @param boolean $shadow The shadow. |
||
828 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
829 | */ |
||
830 | public function setShadow($shadow) { |
||
834 | |||
835 | /** |
||
836 | * Set the shape. |
||
837 | * |
||
838 | * @param string $shape The shape. |
||
839 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
840 | */ |
||
841 | public function setShape($shape) { |
||
845 | |||
846 | /** |
||
847 | * Set the shared. |
||
848 | * |
||
849 | * @param boolean $shared The shared. |
||
850 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
851 | */ |
||
852 | public function setShared($shared) { |
||
856 | |||
857 | /** |
||
858 | * Set the snap. |
||
859 | * |
||
860 | * @param integer $snap The snap. |
||
861 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
862 | */ |
||
863 | public function setSnap($snap) { |
||
867 | |||
868 | /** |
||
869 | * Set the split. |
||
870 | * |
||
871 | * @param boolean $split The split. |
||
872 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
873 | */ |
||
874 | public function setSplit($split) { |
||
878 | |||
879 | /** |
||
880 | * Set the style. |
||
881 | * |
||
882 | * @param array $style The style. |
||
883 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
884 | */ |
||
885 | public function setStyle(array $style = null) { |
||
889 | |||
890 | /** |
||
891 | * Set the use HTML. |
||
892 | * |
||
893 | * @param boolean $useHTML The use HTML. |
||
894 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
895 | */ |
||
896 | public function setUseHTML($useHTML) { |
||
900 | |||
901 | /** |
||
902 | * Set the value decimals. |
||
903 | * |
||
904 | * @param integer $valueDecimals The value decimals. |
||
905 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
906 | */ |
||
907 | public function setValueDecimals($valueDecimals) { |
||
911 | |||
912 | /** |
||
913 | * Set the value prefix. |
||
914 | * |
||
915 | * @param string $valuePrefix The value prefix. |
||
916 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
917 | */ |
||
918 | public function setValuePrefix($valuePrefix) { |
||
922 | |||
923 | /** |
||
924 | * Set the value suffix. |
||
925 | * |
||
926 | * @param string $valueSuffix The value suffix. |
||
927 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
928 | */ |
||
929 | public function setValueSuffix($valueSuffix) { |
||
933 | |||
934 | /** |
||
935 | * Set the x date format. |
||
936 | * |
||
937 | * @param string $xDateFormat The x date format. |
||
938 | * @return \WBW\Bundle\HighchartsBundle\API\Chart\HighchartsTooltip Returns the highcharts tooltip. |
||
939 | */ |
||
940 | public function setXDateFormat($xDateFormat) { |
||
944 | |||
945 | /** |
||
946 | * Convert into an array representing this instance. |
||
947 | * |
||
948 | * @return array Returns an array representing this instance. |
||
949 | */ |
||
950 | public function toArray() { |
||
1045 | |||
1046 | } |
||
1047 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.