Complex classes like HighchartsLang 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 HighchartsLang, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
25 | final class HighchartsLang implements JsonSerializable { |
||
26 | |||
27 | /** |
||
28 | * Context button title. |
||
29 | * |
||
30 | * @var string |
||
31 | * @since 3.0 |
||
32 | */ |
||
33 | private $contextButtonTitle = "Chart context menu"; |
||
34 | |||
35 | /** |
||
36 | * Decimal point. |
||
37 | * |
||
38 | * @var string |
||
39 | * @since 1.2.2 |
||
40 | */ |
||
41 | private $decimalPoint = "."; |
||
42 | |||
43 | /** |
||
44 | * Download JPEG. |
||
45 | * |
||
46 | * @var string |
||
47 | * @since 2.0 |
||
48 | */ |
||
49 | private $downloadJPEG = "Download JPEG image"; |
||
50 | |||
51 | /** |
||
52 | * Download PDF. |
||
53 | * |
||
54 | * @var string |
||
55 | * @since 2.0 |
||
56 | */ |
||
57 | private $downloadPDF = "Download PDF document"; |
||
58 | |||
59 | /** |
||
60 | * Download PNG. |
||
61 | * |
||
62 | * @var string |
||
63 | * @since 2.0 |
||
64 | */ |
||
65 | private $downloadPNG = "Download PNG image"; |
||
66 | |||
67 | /** |
||
68 | * Download SVG. |
||
69 | * |
||
70 | * @var string |
||
71 | * @since 2.0 |
||
72 | */ |
||
73 | private $downloadSVG = "Download SVG vector image"; |
||
74 | |||
75 | /** |
||
76 | * Drill up text. |
||
77 | * |
||
78 | * @var string |
||
79 | * @since 3.0.8 |
||
80 | */ |
||
81 | private $drillUpText = "Back to {series.name}"; |
||
82 | |||
83 | /** |
||
84 | * Invalid date. |
||
85 | * |
||
86 | * @var string |
||
87 | * @since 4.1.8 |
||
88 | */ |
||
89 | private $invalidDate; |
||
90 | |||
91 | /** |
||
92 | * Loading. |
||
93 | * |
||
94 | * @var string |
||
95 | */ |
||
96 | private $loading = "Loading..."; |
||
97 | |||
98 | /** |
||
99 | * Months. |
||
100 | * |
||
101 | * @var array |
||
102 | */ |
||
103 | private $months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; |
||
104 | |||
105 | /** |
||
106 | * No data. |
||
107 | * |
||
108 | * @var string |
||
109 | * @since 3.0.8 |
||
110 | */ |
||
111 | private $noData = "No data to display"; |
||
112 | |||
113 | /** |
||
114 | * Numeric symbol magnitude. |
||
115 | * |
||
116 | * @var integer |
||
117 | * @since 5.0.3 |
||
118 | */ |
||
119 | private $numericSymbolMagnitude = 1000; |
||
120 | |||
121 | /** |
||
122 | * Numeric symbols. |
||
123 | * |
||
124 | * @var array |
||
125 | * @since 2.3.0 |
||
126 | */ |
||
127 | private $numericSymbols = ["k", "M", "G", "T", "P", "E"]; |
||
128 | |||
129 | /** |
||
130 | * Print chart. |
||
131 | * |
||
132 | * @var string |
||
133 | * @since 3.0.1 |
||
134 | */ |
||
135 | private $printChart = "Print chart"; |
||
136 | |||
137 | /** |
||
138 | * Reset zoom. |
||
139 | * |
||
140 | * @var string |
||
141 | * @since 1.2.4 |
||
142 | */ |
||
143 | private $resetZoom = "Reset zoom"; |
||
144 | |||
145 | /** |
||
146 | * Reset zoom title. |
||
147 | * |
||
148 | * @var string |
||
149 | * @since 1.2.4 |
||
150 | */ |
||
151 | private $resetZoomTitle = "Reset zoom level 1:1"; |
||
152 | |||
153 | /** |
||
154 | * Short months. |
||
155 | * |
||
156 | * @var array |
||
157 | */ |
||
158 | private $shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; |
||
159 | |||
160 | /** |
||
161 | * Short weekdays. |
||
162 | * |
||
163 | * @var array |
||
164 | * @since 4.2.4 |
||
165 | */ |
||
166 | private $shortWeekdays; |
||
167 | |||
168 | /** |
||
169 | * Thousands sep. |
||
170 | * |
||
171 | * @var string |
||
172 | * @since 1.2.2 |
||
173 | */ |
||
174 | private $thousandsSep; |
||
175 | |||
176 | /** |
||
177 | * Weekdays. |
||
178 | * |
||
179 | * @var array |
||
180 | */ |
||
181 | private $weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; |
||
182 | |||
183 | /** |
||
184 | * Constructor. |
||
185 | * |
||
186 | * @param boolean $ignoreDefaultValues Ignore the default values. |
||
187 | */ |
||
188 | public function __construct($ignoreDefaultValues = true) { |
||
193 | |||
194 | /** |
||
195 | * Clear. |
||
196 | * |
||
197 | * @return void |
||
198 | */ |
||
199 | public function clear() { |
||
261 | |||
262 | /** |
||
263 | * Get the context button title. |
||
264 | * |
||
265 | * @return string Returns the context button title. |
||
266 | */ |
||
267 | public function getContextButtonTitle() { |
||
270 | |||
271 | /** |
||
272 | * Get the decimal point. |
||
273 | * |
||
274 | * @return string Returns the decimal point. |
||
275 | */ |
||
276 | public function getDecimalPoint() { |
||
279 | |||
280 | /** |
||
281 | * Get the download JPEG. |
||
282 | * |
||
283 | * @return string Returns the download JPEG. |
||
284 | */ |
||
285 | public function getDownloadJPEG() { |
||
288 | |||
289 | /** |
||
290 | * Get the download PDF. |
||
291 | * |
||
292 | * @return string Returns the download PDF. |
||
293 | */ |
||
294 | public function getDownloadPDF() { |
||
297 | |||
298 | /** |
||
299 | * Get the download PNG. |
||
300 | * |
||
301 | * @return string Returns the download PNG. |
||
302 | */ |
||
303 | public function getDownloadPNG() { |
||
306 | |||
307 | /** |
||
308 | * Get the download SVG. |
||
309 | * |
||
310 | * @return string Returns the download SVG. |
||
311 | */ |
||
312 | public function getDownloadSVG() { |
||
315 | |||
316 | /** |
||
317 | * Get the drill up text. |
||
318 | * |
||
319 | * @return string Returns the drill up text. |
||
320 | */ |
||
321 | public function getDrillUpText() { |
||
324 | |||
325 | /** |
||
326 | * Get the invalid date. |
||
327 | * |
||
328 | * @return string Returns the invalid date. |
||
329 | */ |
||
330 | public function getInvalidDate() { |
||
333 | |||
334 | /** |
||
335 | * Get the loading. |
||
336 | * |
||
337 | * @return string Returns the loading. |
||
338 | */ |
||
339 | public function getLoading() { |
||
342 | |||
343 | /** |
||
344 | * Get the months. |
||
345 | * |
||
346 | * @return array Returns the months. |
||
347 | */ |
||
348 | public function getMonths() { |
||
351 | |||
352 | /** |
||
353 | * Get the no data. |
||
354 | * |
||
355 | * @return string Returns the no data. |
||
356 | */ |
||
357 | public function getNoData() { |
||
360 | |||
361 | /** |
||
362 | * Get the numeric symbol magnitude. |
||
363 | * |
||
364 | * @return integer Returns the numeric symbol magnitude. |
||
365 | */ |
||
366 | public function getNumericSymbolMagnitude() { |
||
369 | |||
370 | /** |
||
371 | * Get the numeric symbols. |
||
372 | * |
||
373 | * @return array Returns the numeric symbols. |
||
374 | */ |
||
375 | public function getNumericSymbols() { |
||
378 | |||
379 | /** |
||
380 | * Get the print chart. |
||
381 | * |
||
382 | * @return string Returns the print chart. |
||
383 | */ |
||
384 | public function getPrintChart() { |
||
387 | |||
388 | /** |
||
389 | * Get the reset zoom. |
||
390 | * |
||
391 | * @return string Returns the reset zoom. |
||
392 | */ |
||
393 | public function getResetZoom() { |
||
396 | |||
397 | /** |
||
398 | * Get the reset zoom title. |
||
399 | * |
||
400 | * @return string Returns the reset zoom title. |
||
401 | */ |
||
402 | public function getResetZoomTitle() { |
||
405 | |||
406 | /** |
||
407 | * Get the short months. |
||
408 | * |
||
409 | * @return array Returns the short months. |
||
410 | */ |
||
411 | public function getShortMonths() { |
||
414 | |||
415 | /** |
||
416 | * Get the short weekdays. |
||
417 | * |
||
418 | * @return array Returns the short weekdays. |
||
419 | */ |
||
420 | public function getShortWeekdays() { |
||
423 | |||
424 | /** |
||
425 | * Get the thousands sep. |
||
426 | * |
||
427 | * @return string Returns the thousands sep. |
||
428 | */ |
||
429 | public function getThousandsSep() { |
||
432 | |||
433 | /** |
||
434 | * Get the weekdays. |
||
435 | * |
||
436 | * @return array Returns the weekdays. |
||
437 | */ |
||
438 | public function getWeekdays() { |
||
441 | |||
442 | /** |
||
443 | * Serialize this instance. |
||
444 | * |
||
445 | * @return array Returns an array representing this instance. |
||
446 | */ |
||
447 | public function jsonSerialize() { |
||
450 | |||
451 | /** |
||
452 | * Set the context button title. |
||
453 | * |
||
454 | * @param string $contextButtonTitle The context button title. |
||
455 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
456 | */ |
||
457 | public function setContextButtonTitle($contextButtonTitle) { |
||
461 | |||
462 | /** |
||
463 | * Set the decimal point. |
||
464 | * |
||
465 | * @param string $decimalPoint The decimal point. |
||
466 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
467 | */ |
||
468 | public function setDecimalPoint($decimalPoint) { |
||
472 | |||
473 | /** |
||
474 | * Set the download JPEG. |
||
475 | * |
||
476 | * @param string $downloadJPEG The download JPEG. |
||
477 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
478 | */ |
||
479 | public function setDownloadJPEG($downloadJPEG) { |
||
483 | |||
484 | /** |
||
485 | * Set the download PDF. |
||
486 | * |
||
487 | * @param string $downloadPDF The download PDF. |
||
488 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
489 | */ |
||
490 | public function setDownloadPDF($downloadPDF) { |
||
494 | |||
495 | /** |
||
496 | * Set the download PNG. |
||
497 | * |
||
498 | * @param string $downloadPNG The download PNG. |
||
499 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
500 | */ |
||
501 | public function setDownloadPNG($downloadPNG) { |
||
505 | |||
506 | /** |
||
507 | * Set the download SVG. |
||
508 | * |
||
509 | * @param string $downloadSVG The download SVG. |
||
510 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
511 | */ |
||
512 | public function setDownloadSVG($downloadSVG) { |
||
516 | |||
517 | /** |
||
518 | * Set the drill up text. |
||
519 | * |
||
520 | * @param string $drillUpText The drill up text. |
||
521 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
522 | */ |
||
523 | public function setDrillUpText($drillUpText) { |
||
527 | |||
528 | /** |
||
529 | * Set the invalid date. |
||
530 | * |
||
531 | * @param string $invalidDate The invalid date. |
||
532 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
533 | */ |
||
534 | public function setInvalidDate($invalidDate) { |
||
538 | |||
539 | /** |
||
540 | * Set the loading. |
||
541 | * |
||
542 | * @param string $loading The loading. |
||
543 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
544 | */ |
||
545 | public function setLoading($loading) { |
||
549 | |||
550 | /** |
||
551 | * Set the months. |
||
552 | * |
||
553 | * @param array $months The months. |
||
554 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
555 | */ |
||
556 | public function setMonths(array $months = null) { |
||
560 | |||
561 | /** |
||
562 | * Set the no data. |
||
563 | * |
||
564 | * @param string $noData The no data. |
||
565 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
566 | */ |
||
567 | public function setNoData($noData) { |
||
571 | |||
572 | /** |
||
573 | * Set the numeric symbol magnitude. |
||
574 | * |
||
575 | * @param integer $numericSymbolMagnitude The numeric symbol magnitude. |
||
576 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
577 | */ |
||
578 | public function setNumericSymbolMagnitude($numericSymbolMagnitude) { |
||
582 | |||
583 | /** |
||
584 | * Set the numeric symbols. |
||
585 | * |
||
586 | * @param array $numericSymbols The numeric symbols. |
||
587 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
588 | */ |
||
589 | public function setNumericSymbols(array $numericSymbols = null) { |
||
593 | |||
594 | /** |
||
595 | * Set the print chart. |
||
596 | * |
||
597 | * @param string $printChart The print chart. |
||
598 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
599 | */ |
||
600 | public function setPrintChart($printChart) { |
||
604 | |||
605 | /** |
||
606 | * Set the reset zoom. |
||
607 | * |
||
608 | * @param string $resetZoom The reset zoom. |
||
609 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
610 | */ |
||
611 | public function setResetZoom($resetZoom) { |
||
615 | |||
616 | /** |
||
617 | * Set the reset zoom title. |
||
618 | * |
||
619 | * @param string $resetZoomTitle The reset zoom title. |
||
620 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
621 | */ |
||
622 | public function setResetZoomTitle($resetZoomTitle) { |
||
626 | |||
627 | /** |
||
628 | * Set the short months. |
||
629 | * |
||
630 | * @param array $shortMonths The short months. |
||
631 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
632 | */ |
||
633 | public function setShortMonths(array $shortMonths = null) { |
||
637 | |||
638 | /** |
||
639 | * Set the short weekdays. |
||
640 | * |
||
641 | * @param array $shortWeekdays The short weekdays. |
||
642 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
643 | */ |
||
644 | public function setShortWeekdays(array $shortWeekdays = null) { |
||
648 | |||
649 | /** |
||
650 | * Set the thousands sep. |
||
651 | * |
||
652 | * @param string $thousandsSep The thousands sep. |
||
653 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
654 | */ |
||
655 | public function setThousandsSep($thousandsSep) { |
||
659 | |||
660 | /** |
||
661 | * Set the weekdays. |
||
662 | * |
||
663 | * @param array $weekdays The weekdays. |
||
664 | * @return \WBW\Bundle\HighchartsBundle\API\Options\HighchartsLang Returns the highcharts lang. |
||
665 | */ |
||
666 | public function setWeekdays(array $weekdays = null) { |
||
670 | |||
671 | /** |
||
672 | * Convert into an array representing this instance. |
||
673 | * |
||
674 | * @return array Returns an array representing this instance. |
||
675 | */ |
||
676 | public function toArray() { |
||
744 | |||
745 | } |
||
746 |
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..