This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Jleagle\BattleNet; |
||
3 | |||
4 | use Jleagle\BattleNet\Exceptions\BattleNetException; |
||
5 | use Jleagle\BattleNet\Request\AbstractBattleNet; |
||
6 | use Jleagle\BattleNet\Responses\Warcraft\AchievementResponse; |
||
7 | use Jleagle\BattleNet\Responses\Warcraft\AuctionResponse; |
||
8 | use Jleagle\BattleNet\Responses\Warcraft\BattleGroupResponse; |
||
9 | use Jleagle\BattleNet\Responses\Warcraft\BattlePetAbilityResponse; |
||
10 | use Jleagle\BattleNet\Responses\Warcraft\BattlePetSpeciesResponse; |
||
11 | use Jleagle\BattleNet\Responses\Warcraft\BattlePetStatsResponse; |
||
12 | use Jleagle\BattleNet\Responses\Warcraft\ChallengeRealmResponse; |
||
13 | use Jleagle\BattleNet\Responses\Warcraft\ChallengeRegionResponse; |
||
14 | use Jleagle\BattleNet\Responses\Warcraft\CharacterAchievementsResponse; |
||
15 | use Jleagle\BattleNet\Responses\Warcraft\CharacterClassResponse; |
||
16 | use Jleagle\BattleNet\Responses\Warcraft\CharacterResponse; |
||
17 | use Jleagle\BattleNet\Responses\Warcraft\GuildAchievementsResponse; |
||
18 | use Jleagle\BattleNet\Responses\Warcraft\GuildPerksResponse; |
||
19 | use Jleagle\BattleNet\Responses\Warcraft\GuildResponse; |
||
20 | use Jleagle\BattleNet\Responses\Warcraft\GuildRewardsResponse; |
||
21 | use Jleagle\BattleNet\Responses\Warcraft\ItemClassesResponse; |
||
22 | use Jleagle\BattleNet\Responses\Warcraft\ItemResponse; |
||
23 | use Jleagle\BattleNet\Responses\Warcraft\ItemSetResponse; |
||
24 | use Jleagle\BattleNet\Responses\Warcraft\PetTypeResponse; |
||
25 | use Jleagle\BattleNet\Responses\Warcraft\PvpLeaderboardResponse; |
||
26 | use Jleagle\BattleNet\Responses\Warcraft\QuestResponse; |
||
27 | use Jleagle\BattleNet\Responses\Warcraft\RaceResponse; |
||
28 | use Jleagle\BattleNet\Responses\Warcraft\RealmResponse; |
||
29 | use Jleagle\BattleNet\Responses\Warcraft\RecipeResponse; |
||
30 | use Jleagle\BattleNet\Responses\Warcraft\SpellResponse; |
||
31 | use Jleagle\BattleNet\Responses\Warcraft\TalentResponse; |
||
32 | |||
33 | class Warcraft extends AbstractBattleNet |
||
34 | { |
||
35 | private $_path = 'wow'; |
||
36 | |||
37 | /** |
||
38 | * @param int $achievementId |
||
39 | * |
||
40 | * @return AchievementResponse |
||
41 | */ |
||
42 | public function getAchievement($achievementId) |
||
43 | { |
||
44 | $data = $this->_get($this->_path . '/achievement/' . $achievementId); |
||
45 | return new AchievementResponse($data); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param string $realmSlug |
||
50 | * |
||
51 | * @return AuctionResponse |
||
52 | * @throws BattleNetException |
||
53 | */ |
||
54 | public function getAuctions($realmSlug) |
||
55 | { |
||
56 | $data = $this->_get($this->_path . '/auction/data/' . $realmSlug); |
||
57 | |||
58 | if(!isset($data['files'][0]['url']) || !isset($data['files'][0]['lastModified'])) |
||
59 | { |
||
60 | throw new BattleNetException('Missing fields from API'); |
||
61 | } |
||
62 | |||
63 | return new AuctionResponse( |
||
64 | [ |
||
65 | 'url' => $data['files'][0]['url'], |
||
66 | 'lastModified' => $data['files'][0]['lastModified'] |
||
67 | ] |
||
68 | ); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * @return BattleGroupResponse[] |
||
73 | */ |
||
74 | public function getBattleGroups() |
||
75 | { |
||
76 | $data = $this->_get($this->_path . '/data/battlegroups'); |
||
77 | |||
78 | $return = []; |
||
79 | foreach($data['battlegroups'] as $battlegroup) |
||
80 | { |
||
81 | $return[] = new BattleGroupResponse($battlegroup); |
||
82 | } |
||
83 | return $return; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * @param int $abilityId |
||
88 | * |
||
89 | * @return BattlePetAbilityResponse |
||
90 | */ |
||
91 | public function getBattlePetAbility($abilityId) |
||
92 | { |
||
93 | $data = $this->_get($this->_path . '/battlePet/ability/' . $abilityId); |
||
94 | return new BattlePetAbilityResponse($data); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param int $speciesId |
||
99 | * |
||
100 | * @return BattlePetSpeciesResponse |
||
101 | */ |
||
102 | public function getBattlePetSpecies($speciesId) |
||
103 | { |
||
104 | $data = $this->_get($this->_path . '/battlePet/species/' . $speciesId); |
||
105 | return new BattlePetSpeciesResponse($data); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @param int $speciesId |
||
110 | * @param int $level |
||
111 | * @param int $breedId |
||
112 | * @param int $qualityId |
||
113 | * |
||
114 | * @return BattlePetStatsResponse |
||
115 | */ |
||
116 | public function getBattlePetStats( |
||
117 | $speciesId, $level = 1, $breedId = 3, $qualityId = 1 |
||
118 | ) |
||
119 | { |
||
120 | $data = $this->_get( |
||
121 | $this->_path . '/battlePet/stats/' . $speciesId, |
||
122 | [ |
||
123 | 'level' => $level, |
||
124 | 'breedId' => $breedId, |
||
125 | 'qualityId' => $qualityId |
||
126 | ] |
||
127 | ); |
||
128 | return new BattlePetStatsResponse($data); |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * @param string $realmSlug |
||
133 | * |
||
134 | * @return ChallengeRealmResponse |
||
135 | */ |
||
136 | public function getChallengeRealmLeaderboard($realmSlug) |
||
137 | { |
||
138 | $data = $this->_get($this->_path . '/challenge/' . $realmSlug); |
||
139 | return new ChallengeRealmResponse($data); |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * @return ChallengeRegionResponse |
||
144 | */ |
||
145 | public function getChallengeRegionLeaderboard() |
||
146 | { |
||
147 | $data = $this->_get($this->_path . '/challenge/region'); |
||
148 | return new ChallengeRegionResponse($data); |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * @param string $realmSlug |
||
153 | * @param string $guildName |
||
154 | * @param array $fields |
||
155 | * |
||
156 | * @return GuildResponse |
||
157 | */ |
||
158 | public function getGuild($realmSlug, $guildName, $fields = []) |
||
159 | { |
||
160 | $fields = implode(',', $fields); |
||
161 | $data = $this->_get( |
||
162 | $this->_path . '/guild/' . $realmSlug . '/' . $guildName, |
||
163 | ['fields' => $fields] |
||
164 | ); |
||
165 | return new GuildResponse($data); |
||
166 | } |
||
167 | |||
168 | /** |
||
169 | * @return GuildAchievementsResponse |
||
170 | */ |
||
171 | public function getGuildAchievements() |
||
172 | { |
||
173 | $data = $this->_get($this->_path . '/data/guild/achievements'); |
||
174 | return new GuildAchievementsResponse($data); |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * @return GuildPerksResponse |
||
179 | */ |
||
180 | public function getGuildPerks() |
||
181 | { |
||
182 | $data = $this->_get($this->_path . '/data/guild/perks'); |
||
183 | return new GuildPerksResponse($data); |
||
184 | } |
||
185 | |||
186 | /** |
||
187 | * @return GuildRewardsResponse |
||
188 | */ |
||
189 | public function getGuildRewards() |
||
190 | { |
||
191 | $data = $this->_get($this->_path . '/data/guild/rewards'); |
||
192 | return new GuildRewardsResponse($data); |
||
193 | } |
||
194 | |||
195 | /** |
||
196 | * @param int $itemId |
||
197 | * |
||
198 | * @return ItemResponse |
||
199 | */ |
||
200 | public function getItem($itemId) |
||
201 | { |
||
202 | $data = $this->_get($this->_path . '/item/' . $itemId); |
||
203 | return new ItemResponse($data); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * @return ItemClassesResponse |
||
208 | */ |
||
209 | public function getItemClasses() |
||
210 | { |
||
211 | $data = $this->_get($this->_path . '/data/item/classes'); |
||
212 | return new ItemClassesResponse($data); |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * @param int $setId |
||
217 | * |
||
218 | * @return ItemSetResponse |
||
219 | */ |
||
220 | public function getItemSet($setId) |
||
221 | { |
||
222 | $data = $this->_get($this->_path . '/item/set/' . $setId); |
||
223 | return new ItemSetResponse($data); |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * @return PetTypeResponse[] |
||
228 | */ |
||
229 | public function getPetTypes() |
||
230 | { |
||
231 | $data = $this->_get($this->_path . '/data/pet/types'); |
||
232 | |||
233 | $return = []; |
||
234 | foreach($data['petTypes'] as $petType) |
||
235 | { |
||
236 | $return[] = new PetTypeResponse($petType); |
||
237 | } |
||
238 | return $return; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * @param string $realmSlug |
||
243 | * @param string $character |
||
244 | * @param array $fields |
||
245 | * |
||
246 | * @return CharacterResponse |
||
247 | */ |
||
248 | public function getCharacter($realmSlug, $character, $fields = []) |
||
249 | { |
||
250 | $fields = implode(',', $fields); |
||
251 | $data = $this->_get( |
||
252 | $this->_path . '/character/' . $realmSlug . '/' . $character, |
||
253 | ['fields' => $fields] |
||
254 | ); |
||
255 | |||
256 | $data['thumbnail'] = 'http://' . $this->_serverLocation . '.battle.net/static-render/' . $this->_serverLocation . '/' . $data['thumbnail']; |
||
257 | $data['characterClass'] = $data['class']; |
||
258 | unset($data['class']); |
||
259 | |||
260 | return new CharacterResponse($data); |
||
261 | } |
||
262 | |||
263 | /** |
||
264 | * @return CharacterAchievementsResponse |
||
265 | */ |
||
266 | public function getCharacterAchievements() |
||
267 | { |
||
268 | $data = $this->_get($this->_path . '/data/character/achievements'); |
||
269 | return new CharacterAchievementsResponse($data); |
||
270 | } |
||
271 | |||
272 | /** |
||
273 | * @return CharacterClassResponse[] |
||
274 | */ |
||
275 | View Code Duplication | public function getCharacterClasses() |
|
0 ignored issues
–
show
|
|||
276 | { |
||
277 | $data = $this->_get($this->_path . '/data/character/classes'); |
||
278 | |||
279 | $return = []; |
||
280 | foreach($data['classes'] as $class) |
||
281 | { |
||
282 | $return[] = new CharacterClassResponse($class); |
||
283 | } |
||
284 | return $return; |
||
285 | } |
||
286 | |||
287 | /** |
||
288 | * @param string $bracket |
||
289 | * |
||
290 | * @return PvpLeaderboardResponse[] |
||
291 | */ |
||
292 | View Code Duplication | public function getPvpLeaderboard($bracket) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
293 | { |
||
294 | $data = $this->_get($this->_path . '/leaderboard/' . $bracket); |
||
295 | |||
296 | $return = []; |
||
297 | foreach($data['rows'] as $class) |
||
298 | { |
||
299 | $return[] = new PvpLeaderboardResponse($class); |
||
300 | } |
||
301 | return $return; |
||
302 | } |
||
303 | |||
304 | /** |
||
305 | * @param int $questId |
||
306 | * |
||
307 | * @return QuestResponse |
||
308 | */ |
||
309 | public function getQuest($questId) |
||
310 | { |
||
311 | $data = $this->_get($this->_path . '/quest/' . $questId); |
||
312 | return new QuestResponse($data); |
||
313 | } |
||
314 | |||
315 | /** |
||
316 | * @return RaceResponse[] |
||
317 | */ |
||
318 | public function getRaces() |
||
319 | { |
||
320 | $data = $this->_get($this->_path . '/data/character/races'); |
||
321 | |||
322 | $return = []; |
||
323 | foreach($data['races'] as $race) |
||
324 | { |
||
325 | $return[] = new RaceResponse($race); |
||
326 | } |
||
327 | return $return; |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * @return RealmResponse[] |
||
332 | */ |
||
333 | public function getRealms() |
||
334 | { |
||
335 | $data = $this->_get($this->_path . '/realm/status'); |
||
336 | |||
337 | $return = []; |
||
338 | foreach($data['realms'] as $realm) |
||
339 | { |
||
340 | $return[] = new RealmResponse($realm); |
||
341 | } |
||
342 | return $return; |
||
343 | } |
||
344 | |||
345 | /** |
||
346 | * @param int $recipeId |
||
347 | * |
||
348 | * @return RecipeResponse |
||
349 | */ |
||
350 | public function getRecipe($recipeId) |
||
351 | { |
||
352 | $data = $this->_get($this->_path . '/recipe/' . $recipeId); |
||
353 | return new RecipeResponse($data); |
||
354 | } |
||
355 | |||
356 | /** |
||
357 | * @param int $spellId |
||
358 | * |
||
359 | * @return SpellResponse |
||
360 | */ |
||
361 | public function getSpell($spellId) |
||
362 | { |
||
363 | $data = $this->_get($this->_path . '/spell/' . $spellId); |
||
364 | return new SpellResponse($data); |
||
365 | } |
||
366 | |||
367 | /** |
||
368 | * @return TalentResponse[] |
||
369 | */ |
||
370 | public function getTalents() |
||
371 | { |
||
372 | $data = $this->_get($this->_path . '/data/talents'); |
||
373 | |||
374 | $return = []; |
||
375 | foreach($data as $talent) |
||
376 | { |
||
377 | $return[] = new TalentResponse($talent); |
||
378 | } |
||
379 | return $return; |
||
380 | } |
||
381 | } |
||
382 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.