Complex classes like WowService 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 WowService, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 11 | class WowService extends BattlenetHttpClient |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * {@inheritdoc} |
||
| 15 | */ |
||
| 16 | protected $gameParam = '/wow'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Get achievement information by id. |
||
| 20 | * |
||
| 21 | * This provides data about an individual achievement |
||
| 22 | * |
||
| 23 | * @param int $achievementId Id of the achievement to retrieve |
||
| 24 | * @param array $options Options |
||
| 25 | * |
||
| 26 | * @return Illuminate\Support\Collection api response |
||
| 27 | */ |
||
| 28 | public function getAchievement($achievementId, array $options = []) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Get auction data. |
||
| 35 | * |
||
| 36 | * Auction APIs currently provide rolling batches of data about current auctions. Fetching auction dumps is a two |
||
| 37 | * step process that involves checking a per-realm index file to determine if a recent dump has been generated and |
||
| 38 | * then fetching the most recently generated dump file if necessary. |
||
| 39 | * |
||
| 40 | * This API resource provides a per-realm list of recently generated auction house data dumps |
||
| 41 | * |
||
| 42 | * @param string $realm Realm being requested |
||
| 43 | * @param array $options Options |
||
| 44 | * |
||
| 45 | * @return Illuminate\Support\Collection api response |
||
| 46 | */ |
||
| 47 | public function getAuctionDataStatus($realm, array $options = []) |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Get boss master list. |
||
| 54 | * |
||
| 55 | * A list of all supported bosses. A 'boss' in this context should be considered a boss encounter, which may include |
||
| 56 | * more than one NPC. |
||
| 57 | * |
||
| 58 | * @param array $options Options |
||
| 59 | * |
||
| 60 | * @return Illuminate\Support\Collection api response |
||
| 61 | */ |
||
| 62 | public function getBossMasterList(array $options = []) |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Get boss information by id. |
||
| 69 | * |
||
| 70 | * The boss API provides information about bosses. A 'boss' in this context should be considered a boss encounter, |
||
| 71 | * which may include more than one NPC. |
||
| 72 | * |
||
| 73 | * @param int $bossId Id of the boss you want to retrieve |
||
| 74 | * @param array $options Options |
||
| 75 | * |
||
| 76 | * @return Illuminate\Support\Collection api response |
||
| 77 | */ |
||
| 78 | public function getBoss($bossId, array $options = []) |
||
| 82 | |||
| 83 | /** |
||
| 84 | * Get realm leaderboards. |
||
| 85 | * |
||
| 86 | * The data in this request has data for all 9 challenge mode maps (currently). The map field includes the current |
||
| 87 | * medal times for each dungeon. Inside each ladder we provide data about each character that was part of each run. |
||
| 88 | * The character data includes the current cached spec of the character while the member field includes the spec of |
||
| 89 | * the character during the challenge mode run. |
||
| 90 | * |
||
| 91 | * @param string $realm Realm's name being requested |
||
| 92 | * @param array $options Options |
||
| 93 | * |
||
| 94 | * @return Illuminate\Support\Collection api response |
||
| 95 | */ |
||
| 96 | public function getRealmLeaderboard($realm, array $options = []) |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Get region leaderboards. |
||
| 103 | * |
||
| 104 | * The region leaderboard has the exact same data format as the realm leaderboards except there is no realm field. |
||
| 105 | * It is simply the top 100 results gathered for each map for all of the available realm leaderboards in a region. |
||
| 106 | * |
||
| 107 | * @param array $options Options |
||
| 108 | * |
||
| 109 | * @return Illuminate\Support\Collection api response |
||
| 110 | */ |
||
| 111 | public function getRegionLeaderboard(array $options = []) |
||
| 115 | |||
| 116 | /** |
||
| 117 | * Get character information. |
||
| 118 | * |
||
| 119 | * The Character Profile API is the primary way to access character information. This Character Profile API can be |
||
| 120 | * used to fetch a single character at a time through an HTTP GET request to a URL describing the character profile |
||
| 121 | * resource. By default, a basic dataset will be returned and with each request and zero or more additional fields |
||
| 122 | * can be retrieved. To access this API, craft a resource URL pointing to the character who's information is to be |
||
| 123 | * retrieved |
||
| 124 | * |
||
| 125 | * @param string $realm Character's realm. Can be provided as the proper realm name or the normalized realm name |
||
| 126 | * @param string $characterName Name of the character you want to retrieve |
||
| 127 | * @param array $options Options |
||
| 128 | * |
||
| 129 | * @return Illuminate\Support\Collection api response |
||
| 130 | */ |
||
| 131 | public function getCharacter($realm, $characterName, array $options = []) |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Get guild profile. |
||
| 138 | * |
||
| 139 | * The guild profile API is the primary way to access guild information. This guild profile API can be used to fetch |
||
| 140 | * a single guild at a time through an HTTP GET request to a url describing the guild profile resource. By default, |
||
| 141 | * a basic dataset will be returned and with each request and zero or more additional fields can be retrieved. |
||
| 142 | * |
||
| 143 | * There are no required query string parameters when accessing this resource, although the fields query string |
||
| 144 | * parameter can optionally be passed to indicate that one or more of the optional datasets is to be retrieved. |
||
| 145 | * Those additional fields are listed in the method titled "Optional Fields". |
||
| 146 | * |
||
| 147 | * @param string $realm Realm the guild lives on |
||
| 148 | * @param string $guildName Name of the guild being retrieved |
||
| 149 | * @param array $options Options |
||
| 150 | * |
||
| 151 | * @return Illuminate\Support\Collection api response |
||
| 152 | */ |
||
| 153 | public function getGuild($realm, $guildName, array $options = []) |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Get guild members. |
||
| 160 | * |
||
| 161 | * This provides a list of characters currently in the guild Roster. |
||
| 162 | * This is a wrapper function for the getGuild data function for easier access. |
||
| 163 | * |
||
| 164 | * @param string $realm Realm the guild lives on |
||
| 165 | * @param string $guildName Name of the guild being retrieved |
||
| 166 | * @param array $options Options |
||
| 167 | * |
||
| 168 | * @return Illuminate\Support\Collection api response |
||
| 169 | */ |
||
| 170 | public function getGuildMembers($realm, $guildName, array $options = []) |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Get item information by id. |
||
| 207 | * |
||
| 208 | * The item API provides detailed item information. This includes item set information if this item is part of a set. |
||
| 209 | * |
||
| 210 | * @param int $itemId Id of the item being retrieved |
||
| 211 | * @param array $options Options |
||
| 212 | * |
||
| 213 | * @return Illuminate\Support\Collection api response |
||
| 214 | */ |
||
| 215 | public function getItem($itemId, array $options = []) |
||
| 219 | |||
| 220 | /** |
||
| 221 | * Get set information by id. |
||
| 222 | * |
||
| 223 | * The item API provides detailed item information. This includes item set information if this item is part of a set. |
||
| 224 | * |
||
| 225 | * @param int $setId Id of the set being requested |
||
| 226 | * @param array $options Options |
||
| 227 | * |
||
| 228 | * @return Illuminate\Support\Collection api response |
||
| 229 | */ |
||
| 230 | public function getItemSet($setId, array $options = []) |
||
| 234 | |||
| 235 | /** |
||
| 236 | * Get mount master list. |
||
| 237 | * |
||
| 238 | * A list of all supported mounts |
||
| 239 | * |
||
| 240 | * @param array $options Options |
||
|
|
|||
| 241 | * |
||
| 242 | * @return Illuminate\Support\Collection api response |
||
| 243 | */ |
||
| 244 | public function getMountMasterList() |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Get pet lists. |
||
| 251 | * |
||
| 252 | * A list of all supported battle and vanity pets |
||
| 253 | * |
||
| 254 | * @param array $options Options |
||
| 255 | * |
||
| 256 | * @return Illuminate\Support\Collection api response |
||
| 257 | */ |
||
| 258 | public function getPetList(array $options = []) |
||
| 262 | |||
| 263 | /** |
||
| 264 | * Get pet ability information by id. |
||
| 265 | * |
||
| 266 | * This provides data about a individual battle pet ability ID. We do not provide the tooltip for the ability yet. |
||
| 267 | * We are working on a better way to provide this since it depends on your pet's species, level and quality rolls. |
||
| 268 | * |
||
| 269 | * @param int $abilityId Id of the ability you want to retrieve |
||
| 270 | * @param array $options Options |
||
| 271 | * |
||
| 272 | * @return Illuminate\Support\Collection api response |
||
| 273 | */ |
||
| 274 | public function getPetAbility($abilityId, array $options = []) |
||
| 278 | |||
| 279 | /** |
||
| 280 | * Get pet species information by id. |
||
| 281 | * |
||
| 282 | * This provides the data about an individual pet species. The species IDs can be found your character profile |
||
| 283 | * using the options pets field. Each species also has data about what it's 6 abilities are. |
||
| 284 | * |
||
| 285 | * @param int $speciesId The species you want to retrieve |
||
| 286 | * @param array $options Options |
||
| 287 | * |
||
| 288 | * @return Illuminate\Support\Collection api response |
||
| 289 | */ |
||
| 290 | public function getPetSpecies($speciesId, array $options = []) |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Get pet stats by species id. |
||
| 297 | * |
||
| 298 | * Retrieve detailed information about a given species of pet |
||
| 299 | * |
||
| 300 | * @param int $speciesId Pet's species id. This can be found by querying a users' list of pets via the Character Profile API |
||
| 301 | * @param array $options Options |
||
| 302 | * |
||
| 303 | * @return Illuminate\Support\Collection api response |
||
| 304 | */ |
||
| 305 | public function getPetStats($speciesId, array $options = []) |
||
| 324 | |||
| 325 | /** |
||
| 326 | * Get leaderboards. |
||
| 327 | * |
||
| 328 | * The Leaderboard API endpoint provides leaderboard information for the 2v2, 3v3, 5v5 and Rated Battleground |
||
| 329 | * leaderboards. |
||
| 330 | * |
||
| 331 | * @param int $bracket Type of leaderboard you want to retrieve. Example: 2v2, 3v3, 5v5, and rbg |
||
| 332 | * @param array $options Options |
||
| 333 | * |
||
| 334 | * @return Illuminate\Support\Collection api response |
||
| 335 | */ |
||
| 336 | public function getLeaderboards($bracket, array $options = []) |
||
| 340 | |||
| 341 | /** |
||
| 342 | * Get quest information by id. |
||
| 343 | * |
||
| 344 | * Retrieve metadata for a given quest. |
||
| 345 | * |
||
| 346 | * @param int $questId Id of the quest you want to retrieve |
||
| 347 | * @param array $options Options |
||
| 348 | * |
||
| 349 | * @return Illuminate\Support\Collection api response |
||
| 350 | */ |
||
| 351 | public function getQuest($questId, array $options = []) |
||
| 355 | |||
| 356 | /** |
||
| 357 | * Get realm status. |
||
| 358 | * |
||
| 359 | * The realm status API allows developers to retrieve realm status information. This information is limited to |
||
| 360 | * whether or not the realm is up, the type and state of the realm, the current population, and the status of the |
||
| 361 | * two world PvP zones |
||
| 362 | * |
||
| 363 | * @param array $options Options |
||
| 364 | * |
||
| 365 | * @return Illuminate\Support\Collection api response |
||
| 366 | */ |
||
| 367 | public function getRealmStatus(array $options = []) |
||
| 371 | |||
| 372 | /** |
||
| 373 | * Get recipe information by id. |
||
| 374 | * |
||
| 375 | * The recipe API provides basic recipe information |
||
| 376 | * |
||
| 377 | * @param int $recipeId Id for the desired recipe |
||
| 378 | * @param array $options Options |
||
| 379 | * |
||
| 380 | * @return Illuminate\Support\Collection api response |
||
| 381 | */ |
||
| 382 | public function getRecipe($recipeId, array $options = []) |
||
| 386 | |||
| 387 | /** |
||
| 388 | * Get spell information by id. |
||
| 389 | * |
||
| 390 | * The spell API provides some information about spells |
||
| 391 | * |
||
| 392 | * @param int $spellId Id of the desired spell |
||
| 393 | * @param array $options Options |
||
| 394 | * |
||
| 395 | * @return Illuminate\Support\Collection api response |
||
| 396 | */ |
||
| 397 | public function getSpell($spellId, array $options = []) |
||
| 401 | |||
| 402 | /** |
||
| 403 | * Get zone master list. |
||
| 404 | * |
||
| 405 | * A list of all supported zones and their bosses. A 'zone' in this context should be considered a dungeon, or a |
||
| 406 | * raid, not a zone as in a world zone. A 'boss' in this context should be considered a boss encounter, which may |
||
| 407 | * include more than one NPC. |
||
| 408 | * |
||
| 409 | * @param array $options Options |
||
| 410 | * |
||
| 411 | * @return Illuminate\Support\Collection api response |
||
| 412 | */ |
||
| 413 | public function getZonesMasterList(array $options = []) |
||
| 417 | |||
| 418 | /** |
||
| 419 | * Get zone information by id. |
||
| 420 | * |
||
| 421 | * The Zone API provides some information about zones. |
||
| 422 | * |
||
| 423 | * @param int $zoneId Id of the zone you want to retrieve |
||
| 424 | * @param array $options Options |
||
| 425 | * |
||
| 426 | * @return Illuminate\Support\Collection api response |
||
| 427 | */ |
||
| 428 | public function getZone($zoneId, array $options = []) |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Get data battlegroups. |
||
| 435 | * |
||
| 436 | * The battlegroups data API provides the list of battlegroups for this region. Please note the trailing '/' on this URL |
||
| 437 | * |
||
| 438 | * @param array $options Options |
||
| 439 | * |
||
| 440 | * @return Illuminate\Support\Collection api response |
||
| 441 | */ |
||
| 442 | public function getDataBattlegroups(array $options = []) |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Get data character races. |
||
| 449 | * |
||
| 450 | * The character races data API provides a list of each race and their associated faction, name, unique ID, and skin |
||
| 451 | * |
||
| 452 | * @param array $options Options |
||
| 453 | * |
||
| 454 | * @return Illuminate\Support\Collection api response |
||
| 455 | */ |
||
| 456 | public function getDataCharacterRaces(array $options = []) |
||
| 460 | |||
| 461 | /** |
||
| 462 | * Get data character classes. |
||
| 463 | * |
||
| 464 | * The character classes data API provides a list of character classes |
||
| 465 | * |
||
| 466 | * @param array $options Options |
||
| 467 | * |
||
| 468 | * @return Illuminate\Support\Collection api response |
||
| 469 | */ |
||
| 470 | public function getDataCharacterClasses(array $options = []) |
||
| 474 | |||
| 475 | /** |
||
| 476 | * Get data character achievements. |
||
| 477 | * |
||
| 478 | * The character achievements data API provides a list of all of the achievements that characters can earn as well |
||
| 479 | * as the category structure and hierarchy |
||
| 480 | * |
||
| 481 | * @param array $options Options |
||
| 482 | * |
||
| 483 | * @return Illuminate\Support\Collection api response |
||
| 484 | */ |
||
| 485 | public function getDataCharacterAchievements(array $options = []) |
||
| 489 | |||
| 490 | /** |
||
| 491 | * Get data guild rewards. |
||
| 492 | * |
||
| 493 | * The guild rewards data API provides a list of all guild rewards |
||
| 494 | * |
||
| 495 | * @param array $options Options |
||
| 496 | * |
||
| 497 | * @return Illuminate\Support\Collection api response |
||
| 498 | */ |
||
| 499 | public function getDataGuildRewards(array $options = []) |
||
| 503 | |||
| 504 | /** |
||
| 505 | * Get data guild perks. |
||
| 506 | * |
||
| 507 | * The guild perks data API provides a list of all guild perks |
||
| 508 | * |
||
| 509 | * @param array $options Options |
||
| 510 | * |
||
| 511 | * @return Illuminate\Support\Collection api response |
||
| 512 | */ |
||
| 513 | public function getDataGuildPerks(array $options = []) |
||
| 517 | |||
| 518 | /** |
||
| 519 | * Get data guild achievements. |
||
| 520 | * |
||
| 521 | * The guild achievements data API provides a list of all of the achievements that guilds can earn as well as the |
||
| 522 | * category structure and hierarchy |
||
| 523 | * |
||
| 524 | * @param array $options Options |
||
| 525 | * |
||
| 526 | * @return Illuminate\Support\Collection api response |
||
| 527 | */ |
||
| 528 | public function getDataGuildAchievements(array $options = []) |
||
| 532 | |||
| 533 | /** |
||
| 534 | * Get data item classes. |
||
| 535 | * |
||
| 536 | * The item classes data API provides a list of item classes |
||
| 537 | * |
||
| 538 | * @param array $options Options |
||
| 539 | * |
||
| 540 | * @return Illuminate\Support\Collection api response |
||
| 541 | */ |
||
| 542 | public function getDataItemClasses(array $options = []) |
||
| 546 | |||
| 547 | /** |
||
| 548 | * Get data talents. |
||
| 549 | * |
||
| 550 | * The talents data API provides a list of talents, specs and glyphs for each class |
||
| 551 | * |
||
| 552 | * @param array $options Options |
||
| 553 | * |
||
| 554 | * @return Illuminate\Support\Collection api response |
||
| 555 | */ |
||
| 556 | public function getDataTalents(array $options = []) |
||
| 560 | |||
| 561 | /** |
||
| 562 | * Get data pet types. |
||
| 563 | * |
||
| 564 | * The different bat pet types (including what they are strong and weak against) |
||
| 565 | * |
||
| 566 | * @param array $options Options |
||
| 567 | * |
||
| 568 | * @return null|\Xklusive\BattlenetApi\Collection api response |
||
| 569 | */ |
||
| 570 | public function getDataPetTypes(array $options = []) |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Get profile characters. |
||
| 577 | * |
||
| 578 | * This provides data about the current logged in OAuth user's - or the given user - WoW profile |
||
| 579 | * |
||
| 580 | * @param array $options Options |
||
| 581 | * |
||
| 582 | * @return Illuminate\Support\Collection api response |
||
| 583 | */ |
||
| 584 | public function getProfileCharacters(array $options = []) |
||
| 607 | } |
||
| 608 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.