Complex classes like Condition 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 Condition, and based on these observations, apply Extract Interface, too.
| 1 | <?php declare(strict_types=1); |
||
| 17 | abstract class Condition extends AbstractResource implements ConditionInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var Image |
||
| 21 | */ |
||
| 22 | protected $image; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Location |
||
| 26 | */ |
||
| 27 | protected $display_location; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var Location |
||
| 31 | */ |
||
| 32 | protected $observation_location; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var array |
||
| 36 | */ |
||
| 37 | protected $estimated; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | protected $station_id; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | protected $observation_time; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | protected $observation_time_rfc822; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var string |
||
| 56 | */ |
||
| 57 | protected $observation_epoch; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var string |
||
| 61 | */ |
||
| 62 | protected $local_time_rfc822; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var string |
||
| 66 | */ |
||
| 67 | protected $local_epoch; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var string |
||
| 71 | */ |
||
| 72 | protected $local_tz_short; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var string |
||
| 76 | */ |
||
| 77 | protected $local_tz_long; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var string |
||
| 81 | */ |
||
| 82 | protected $local_tz_offset; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var string |
||
| 86 | */ |
||
| 87 | protected $weather; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var string |
||
| 91 | */ |
||
| 92 | protected $temperature_string; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var float |
||
| 96 | */ |
||
| 97 | protected $temp_f; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var float |
||
| 101 | */ |
||
| 102 | protected $temp_c; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var string |
||
| 106 | */ |
||
| 107 | protected $relative_humidity; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @var string |
||
| 111 | */ |
||
| 112 | protected $wind_string; |
||
| 113 | |||
| 114 | /** |
||
| 115 | * @var string |
||
| 116 | */ |
||
| 117 | protected $wind_dir; |
||
| 118 | |||
| 119 | /** |
||
| 120 | * @var string |
||
| 121 | */ |
||
| 122 | protected $wind_degrees; |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @var string |
||
| 126 | */ |
||
| 127 | protected $wind_mph; |
||
| 128 | |||
| 129 | /** |
||
| 130 | * @var string |
||
| 131 | */ |
||
| 132 | protected $wind_gust_mph; |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @var string |
||
| 136 | */ |
||
| 137 | protected $wind_kph; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @var string |
||
| 141 | */ |
||
| 142 | protected $wind_gust_kph; |
||
| 143 | |||
| 144 | /** |
||
| 145 | * @var string |
||
| 146 | */ |
||
| 147 | protected $pressure_mb; |
||
| 148 | |||
| 149 | /** |
||
| 150 | * @var string |
||
| 151 | */ |
||
| 152 | protected $pressure_in; |
||
| 153 | |||
| 154 | /** |
||
| 155 | * @var string |
||
| 156 | */ |
||
| 157 | protected $pressure_trend; |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @var string |
||
| 161 | */ |
||
| 162 | protected $dewpoint_string; |
||
| 163 | |||
| 164 | /** |
||
| 165 | * @var int |
||
| 166 | */ |
||
| 167 | protected $dewpoint_f; |
||
| 168 | |||
| 169 | /** |
||
| 170 | * @var int |
||
| 171 | */ |
||
| 172 | protected $dewpoint_c; |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @var string |
||
| 176 | */ |
||
| 177 | protected $heat_index_string; |
||
| 178 | |||
| 179 | /** |
||
| 180 | * @var string |
||
| 181 | */ |
||
| 182 | protected $heat_index_f; |
||
| 183 | |||
| 184 | /** |
||
| 185 | * @var string |
||
| 186 | */ |
||
| 187 | protected $heat_index_c; |
||
| 188 | |||
| 189 | /** |
||
| 190 | * @var string |
||
| 191 | */ |
||
| 192 | protected $windchill_string; |
||
| 193 | |||
| 194 | /** |
||
| 195 | * @var string |
||
| 196 | */ |
||
| 197 | protected $windchill_f; |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @var string |
||
| 201 | */ |
||
| 202 | protected $windchill_c; |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @var string |
||
| 206 | */ |
||
| 207 | protected $feelslike_string; |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @var string |
||
| 211 | */ |
||
| 212 | protected $feelslike_f; |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @var string |
||
| 216 | */ |
||
| 217 | protected $feelslike_c; |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @var string |
||
| 221 | */ |
||
| 222 | protected $visibility_mi; |
||
| 223 | |||
| 224 | /** |
||
| 225 | * @var string |
||
| 226 | */ |
||
| 227 | protected $visibility_km; |
||
| 228 | |||
| 229 | /** |
||
| 230 | * @var string |
||
| 231 | */ |
||
| 232 | protected $solarradiation; |
||
| 233 | |||
| 234 | /** |
||
| 235 | * @var string |
||
| 236 | */ |
||
| 237 | protected $UV; |
||
| 238 | |||
| 239 | /** |
||
| 240 | * @var string |
||
| 241 | */ |
||
| 242 | protected $precip_1hr_string; |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @var string |
||
| 246 | */ |
||
| 247 | protected $precip_1hr_in; |
||
| 248 | |||
| 249 | /** |
||
| 250 | * @var string |
||
| 251 | */ |
||
| 252 | protected $precip_1hr_metric; |
||
| 253 | |||
| 254 | /** |
||
| 255 | * @var string |
||
| 256 | */ |
||
| 257 | protected $precip_today_string; |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @var string |
||
| 261 | */ |
||
| 262 | protected $precip_today_in; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * @var string |
||
| 266 | */ |
||
| 267 | protected $precip_today_metric; |
||
| 268 | |||
| 269 | /** |
||
| 270 | * @var string |
||
| 271 | */ |
||
| 272 | protected $icon; |
||
| 273 | |||
| 274 | /** |
||
| 275 | * @var string |
||
| 276 | */ |
||
| 277 | protected $icon_url; |
||
| 278 | |||
| 279 | /** |
||
| 280 | * @var string |
||
| 281 | */ |
||
| 282 | protected $forecast_url; |
||
| 283 | |||
| 284 | /** |
||
| 285 | * @var string |
||
| 286 | */ |
||
| 287 | protected $history_url; |
||
| 288 | |||
| 289 | /** |
||
| 290 | * @var string |
||
| 291 | */ |
||
| 292 | protected $ob_url; |
||
| 293 | |||
| 294 | /** |
||
| 295 | * @var string |
||
| 296 | */ |
||
| 297 | protected $nowcast; |
||
| 298 | |||
| 299 | /** |
||
| 300 | * @return Image |
||
| 301 | */ |
||
| 302 | public function image() : Image |
||
| 306 | |||
| 307 | /** |
||
| 308 | * @return Location |
||
| 309 | */ |
||
| 310 | public function displayLocation() : Location |
||
| 314 | |||
| 315 | /** |
||
| 316 | * @return Location |
||
| 317 | */ |
||
| 318 | public function observationLocation() : Location |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @return array |
||
| 325 | */ |
||
| 326 | public function estimated() : array |
||
| 330 | |||
| 331 | /** |
||
| 332 | * @return string |
||
| 333 | */ |
||
| 334 | public function stationId() : string |
||
| 338 | |||
| 339 | /** |
||
| 340 | * @return string |
||
| 341 | */ |
||
| 342 | public function observationTime() : string |
||
| 346 | |||
| 347 | /** |
||
| 348 | * @return string |
||
| 349 | */ |
||
| 350 | public function observationTimeRfc822() : string |
||
| 354 | |||
| 355 | /** |
||
| 356 | * @return string |
||
| 357 | */ |
||
| 358 | public function observationEpoch() : string |
||
| 362 | |||
| 363 | /** |
||
| 364 | * @return string |
||
| 365 | */ |
||
| 366 | public function localTimeRfc822() : string |
||
| 370 | |||
| 371 | /** |
||
| 372 | * @return string |
||
| 373 | */ |
||
| 374 | public function localEpoch() : string |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @return string |
||
| 381 | */ |
||
| 382 | public function localTzShort() : string |
||
| 386 | |||
| 387 | /** |
||
| 388 | * @return string |
||
| 389 | */ |
||
| 390 | public function localTzLong() : string |
||
| 394 | |||
| 395 | /** |
||
| 396 | * @return string |
||
| 397 | */ |
||
| 398 | public function localTzOffset() : string |
||
| 402 | |||
| 403 | /** |
||
| 404 | * @return string |
||
| 405 | */ |
||
| 406 | public function weather() : string |
||
| 410 | |||
| 411 | /** |
||
| 412 | * @return string |
||
| 413 | */ |
||
| 414 | public function temperatureString() : string |
||
| 418 | |||
| 419 | /** |
||
| 420 | * @return float |
||
| 421 | */ |
||
| 422 | public function tempF() : float |
||
| 426 | |||
| 427 | /** |
||
| 428 | * @return float |
||
| 429 | */ |
||
| 430 | public function tempC() : float |
||
| 434 | |||
| 435 | /** |
||
| 436 | * @return string |
||
| 437 | */ |
||
| 438 | public function relativeHumidity() : string |
||
| 442 | |||
| 443 | /** |
||
| 444 | * @return string |
||
| 445 | */ |
||
| 446 | public function windString() : string |
||
| 450 | |||
| 451 | /** |
||
| 452 | * @return string |
||
| 453 | */ |
||
| 454 | public function windDir() : string |
||
| 458 | |||
| 459 | /** |
||
| 460 | * @return string |
||
| 461 | */ |
||
| 462 | public function windDegrees() : string |
||
| 466 | |||
| 467 | /** |
||
| 468 | * @return string |
||
| 469 | */ |
||
| 470 | public function windMph() : string |
||
| 474 | |||
| 475 | /** |
||
| 476 | * @return string |
||
| 477 | */ |
||
| 478 | public function windGustMph() : string |
||
| 482 | |||
| 483 | /** |
||
| 484 | * @return string |
||
| 485 | */ |
||
| 486 | public function windKph() : string |
||
| 490 | |||
| 491 | /** |
||
| 492 | * @return string |
||
| 493 | */ |
||
| 494 | public function windGustKph() : string |
||
| 498 | |||
| 499 | /** |
||
| 500 | * @return string |
||
| 501 | */ |
||
| 502 | public function pressureMb() : string |
||
| 506 | |||
| 507 | /** |
||
| 508 | * @return string |
||
| 509 | */ |
||
| 510 | public function pressureIn() : string |
||
| 514 | |||
| 515 | /** |
||
| 516 | * @return string |
||
| 517 | */ |
||
| 518 | public function pressureTrend() : string |
||
| 522 | |||
| 523 | /** |
||
| 524 | * @return string |
||
| 525 | */ |
||
| 526 | public function dewpointString() : string |
||
| 530 | |||
| 531 | /** |
||
| 532 | * @return int |
||
| 533 | */ |
||
| 534 | public function dewpointF() : int |
||
| 538 | |||
| 539 | /** |
||
| 540 | * @return int |
||
| 541 | */ |
||
| 542 | public function dewpointC() : int |
||
| 546 | |||
| 547 | /** |
||
| 548 | * @return string |
||
| 549 | */ |
||
| 550 | public function heatIndexString() : string |
||
| 554 | |||
| 555 | /** |
||
| 556 | * @return string |
||
| 557 | */ |
||
| 558 | public function heatIndexF() : string |
||
| 562 | |||
| 563 | /** |
||
| 564 | * @return string |
||
| 565 | */ |
||
| 566 | public function heatIndexC() : string |
||
| 570 | |||
| 571 | /** |
||
| 572 | * @return string |
||
| 573 | */ |
||
| 574 | public function windchillString() : string |
||
| 578 | |||
| 579 | /** |
||
| 580 | * @return string |
||
| 581 | */ |
||
| 582 | public function windchillF() : string |
||
| 586 | |||
| 587 | /** |
||
| 588 | * @return string |
||
| 589 | */ |
||
| 590 | public function windchillC() : string |
||
| 594 | |||
| 595 | /** |
||
| 596 | * @return string |
||
| 597 | */ |
||
| 598 | public function feelslikeString() : string |
||
| 602 | |||
| 603 | /** |
||
| 604 | * @return string |
||
| 605 | */ |
||
| 606 | public function feelslikeF() : string |
||
| 610 | |||
| 611 | /** |
||
| 612 | * @return string |
||
| 613 | */ |
||
| 614 | public function feelslikeC() : string |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @return string |
||
| 621 | */ |
||
| 622 | public function visibilityMi() : string |
||
| 626 | |||
| 627 | /** |
||
| 628 | * @return string |
||
| 629 | */ |
||
| 630 | public function visibilityKm() : string |
||
| 634 | |||
| 635 | /** |
||
| 636 | * @return string |
||
| 637 | */ |
||
| 638 | public function solarradiation() : string |
||
| 642 | |||
| 643 | /** |
||
| 644 | * @return string |
||
| 645 | */ |
||
| 646 | public function uV() : string |
||
| 650 | |||
| 651 | /** |
||
| 652 | * @return string |
||
| 653 | */ |
||
| 654 | public function precip1hrString() : string |
||
| 658 | |||
| 659 | /** |
||
| 660 | * @return string |
||
| 661 | */ |
||
| 662 | public function precip1hrIn() : string |
||
| 666 | |||
| 667 | /** |
||
| 668 | * @return string |
||
| 669 | */ |
||
| 670 | public function precip1hrMetric() : string |
||
| 674 | |||
| 675 | /** |
||
| 676 | * @return string |
||
| 677 | */ |
||
| 678 | public function precipTodayString() : string |
||
| 682 | |||
| 683 | /** |
||
| 684 | * @return string |
||
| 685 | */ |
||
| 686 | public function precipTodayIn() : string |
||
| 690 | |||
| 691 | /** |
||
| 692 | * @return string |
||
| 693 | */ |
||
| 694 | public function precipTodayMetric() : string |
||
| 698 | |||
| 699 | /** |
||
| 700 | * @return string |
||
| 701 | */ |
||
| 702 | public function icon() : string |
||
| 706 | |||
| 707 | /** |
||
| 708 | * @return string |
||
| 709 | */ |
||
| 710 | public function iconUrl() : string |
||
| 714 | |||
| 715 | /** |
||
| 716 | * @return string |
||
| 717 | */ |
||
| 718 | public function forecastUrl() : string |
||
| 722 | |||
| 723 | /** |
||
| 724 | * @return string |
||
| 725 | */ |
||
| 726 | public function historyUrl() : string |
||
| 730 | |||
| 731 | /** |
||
| 732 | * @return string |
||
| 733 | */ |
||
| 734 | public function obUrl() : string |
||
| 738 | |||
| 739 | /** |
||
| 740 | * @return string |
||
| 741 | */ |
||
| 742 | public function nowcast() : string |
||
| 746 | } |
||
| 747 |