1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi; |
4
|
|
|
|
5
|
|
|
use Kubinashi\BattlenetApi\Model\AuthenticationModel; |
6
|
|
|
use Kubinashi\BattlenetApi\Model\Franchises; |
7
|
|
|
use Kubinashi\BattlenetApi\Model\RequestModel; |
8
|
|
|
use Kubinashi\BattlenetApi\Service\RequestService; |
9
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\AchievementsValueObject; |
10
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\AppearanceValueObject; |
11
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\CharacterProfileValueObject; |
12
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\EmblemValueObject; |
13
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\GuildValueObject; |
14
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\HunterPet\HunterPetSpecValueObject; |
15
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\HunterPet\HunterPetValueObject; |
16
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Mount\MountsValueObject; |
17
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Mount\MountValueObject; |
18
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pet\PetStatValueObject; |
19
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pet\PetsValueObject; |
20
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pet\PetValueObject; |
21
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\PetSlotsValueObject; |
22
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Profession\ProfessionsValueObject; |
23
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Profession\ProfessionValueObject; |
24
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Progression\BossValueObject; |
25
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Progression\ProgressionValueObject; |
26
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Progression\RaidValueObject; |
27
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pvp\BracketValueObject; |
28
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pvp\PvpValueObject; |
29
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\QuestsValueObject; |
30
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\ReputationValueObject; |
31
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Talent\SpecValueObject; |
32
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Talent\TalentsValueObject; |
33
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Talent\TalentValueObject; |
34
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\TitleValueObject; |
35
|
|
|
use Kubinashi\BattlenetApi\WorldOfWarcraft\Model\SpellValueObject; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @author Willy Reiche |
39
|
|
|
* @since 2017-07-19 |
40
|
|
|
* @version 1.0 |
41
|
|
|
*/ |
42
|
|
|
class CharacterProfileApi{ |
43
|
|
|
/** |
44
|
|
|
* @var AuthenticationModel |
45
|
|
|
*/ |
46
|
|
|
private $authenticationModel; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var RequestService |
50
|
|
|
*/ |
51
|
|
|
private $requestService; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
private $charName; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @var string |
60
|
|
|
*/ |
61
|
|
|
private $realm; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param AuthenticationModel $authenticationModel |
65
|
|
|
* @param RequestService $requestService |
66
|
|
|
* @param string $charName |
67
|
|
|
* @param string $realm |
68
|
|
|
*/ |
69
|
9 |
|
public function __construct( |
70
|
|
|
AuthenticationModel $authenticationModel, |
71
|
|
|
RequestService $requestService, |
72
|
|
|
$charName, |
73
|
|
|
$realm |
74
|
|
|
) { |
75
|
9 |
|
$this->requestService = $requestService; |
76
|
9 |
|
$this->authenticationModel = $authenticationModel; |
77
|
9 |
|
$this->charName = $charName; |
78
|
9 |
|
$this->realm = $realm; |
79
|
9 |
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* The basic character data |
83
|
|
|
* |
84
|
|
|
* @return CharacterProfileValueObject |
85
|
|
|
*/ |
86
|
1 |
|
public function getCharacterProfile() |
87
|
|
|
{ |
88
|
1 |
|
$requestModel = $this->prepareRequestModel(); |
89
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
90
|
1 |
|
$responseObject = json_decode($response); |
91
|
|
|
|
92
|
1 |
|
$characterProfile = new CharacterProfileValueObject( |
93
|
1 |
|
$responseObject->lastModified, |
94
|
1 |
|
$responseObject->name, |
95
|
1 |
|
$responseObject->realm, |
96
|
1 |
|
$responseObject->battlegroup, |
97
|
1 |
|
$responseObject->class, |
98
|
1 |
|
$responseObject->race, |
99
|
1 |
|
$responseObject->gender, |
100
|
1 |
|
$responseObject->level, |
101
|
1 |
|
$responseObject->achievementPoints, |
102
|
1 |
|
$responseObject->thumbnail, |
103
|
1 |
|
$responseObject->calcClass, |
104
|
1 |
|
$responseObject->faction, |
105
|
1 |
|
$responseObject->totalHonorableKills |
106
|
1 |
|
); |
107
|
|
|
|
108
|
1 |
|
return $characterProfile; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* A map of achievement data including completion timestamps and criteria information |
113
|
|
|
* |
114
|
|
|
* @return AchievementsValueObject |
115
|
|
|
*/ |
116
|
1 |
|
public function getAchievements() |
117
|
|
|
{ |
118
|
1 |
|
$requestModel = $this->prepareRequestModel('achievements'); |
119
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
120
|
1 |
|
$responseObject = json_decode($response); |
121
|
|
|
|
122
|
1 |
|
$achievements = new AchievementsValueObject( |
123
|
1 |
|
$responseObject->achievements->achievementsCompleted, |
124
|
1 |
|
$responseObject->achievements->achievementsCompletedTimestamp, |
125
|
1 |
|
$responseObject->achievements->criteria, |
126
|
1 |
|
$responseObject->achievements->criteriaQuantity, |
127
|
1 |
|
$responseObject->achievements->criteriaTimestamp, |
128
|
1 |
|
$responseObject->achievements->criteriaCreated |
129
|
1 |
|
); |
130
|
|
|
|
131
|
1 |
|
return $achievements; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* A map of a character's appearance settings such as which face texture they've selected and whether or not a healm is visible |
136
|
|
|
* |
137
|
|
|
* @return AppearanceValueObject |
138
|
|
|
*/ |
139
|
1 |
|
public function getAppearance() |
140
|
|
|
{ |
141
|
1 |
|
$requestModel = $this->prepareRequestModel('appearance'); |
142
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
143
|
1 |
|
$responseObject = json_decode($response); |
144
|
|
|
|
145
|
1 |
|
$appearance = new AppearanceValueObject( |
146
|
1 |
|
$responseObject->appearance->faceVariation, |
147
|
1 |
|
$responseObject->appearance->skinColor, |
148
|
1 |
|
$responseObject->appearance->hairVariation, |
149
|
1 |
|
$responseObject->appearance->hairColor, |
150
|
1 |
|
$responseObject->appearance->featureVariation, |
151
|
1 |
|
$responseObject->appearance->showHelm, |
152
|
1 |
|
$responseObject->appearance->showCloak, |
153
|
1 |
|
$responseObject->appearance->customDisplayOptions |
154
|
1 |
|
); |
155
|
|
|
|
156
|
1 |
|
return $appearance; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* A summary of the guild that the character belongs to |
161
|
|
|
* |
162
|
|
|
* @return GuildValueObject |
163
|
|
|
*/ |
164
|
1 |
|
public function getGuild() |
165
|
|
|
{ |
166
|
1 |
|
$requestModel = $this->prepareRequestModel('guild'); |
167
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
168
|
1 |
|
$responseObject = json_decode($response); |
169
|
|
|
|
170
|
1 |
|
$emblemValueObject = $this->prepareEmblem($responseObject->guild->emblem); |
171
|
|
|
|
172
|
1 |
|
$guild = new GuildValueObject( |
173
|
1 |
|
$responseObject->guild->name, |
174
|
1 |
|
$responseObject->guild->realm, |
175
|
1 |
|
$responseObject->guild->battlegroup, |
176
|
1 |
|
$responseObject->guild->members, |
177
|
|
|
$emblemValueObject |
178
|
1 |
|
); |
179
|
|
|
|
180
|
1 |
|
return $guild; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* A list of all of the combat pets obtained by the character |
185
|
|
|
* |
186
|
|
|
* @return HunterPetValueObject[] |
187
|
|
|
*/ |
188
|
1 |
|
public function getHunterPets() |
189
|
|
|
{ |
190
|
1 |
|
$requestModel = $this->prepareRequestModel('hunterPets'); |
191
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
192
|
1 |
|
$responseObject = json_decode($response); |
193
|
|
|
|
194
|
1 |
|
return $this->prepareHunterPets($responseObject); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* A list of all of the mounts obtained by the character |
199
|
|
|
* |
200
|
|
|
* @return MountsValueObject |
201
|
|
|
*/ |
202
|
1 |
View Code Duplication |
public function getMounts() |
|
|
|
|
203
|
|
|
{ |
204
|
1 |
|
$requestModel = $this->prepareRequestModel('mounts'); |
205
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
206
|
1 |
|
$responseObject = json_decode($response); |
207
|
|
|
|
208
|
1 |
|
$collectedMounts = []; |
209
|
1 |
|
foreach ($responseObject->mounts->collected as $mount) { |
210
|
1 |
|
$collectedMounts[] = $this->prepareMountValueObject($mount); |
211
|
1 |
|
} |
212
|
|
|
|
213
|
1 |
|
$mounts = new MountsValueObject( |
214
|
1 |
|
$responseObject->mounts->numCollected, |
215
|
1 |
|
$responseObject->mounts->numNotCollected, |
216
|
|
|
$collectedMounts |
217
|
1 |
|
); |
218
|
|
|
|
219
|
1 |
|
return $mounts; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* A list of the battle pets obtained by the character |
224
|
|
|
* |
225
|
|
|
* @return PetsValueObject |
226
|
|
|
*/ |
227
|
1 |
View Code Duplication |
public function getPets() |
|
|
|
|
228
|
|
|
{ |
229
|
1 |
|
$requestModel = $this->prepareRequestModel('pets'); |
230
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
231
|
1 |
|
$responseObject = json_decode($response); |
232
|
|
|
|
233
|
1 |
|
$collectedPets = []; |
234
|
1 |
|
foreach ($responseObject->pets->collected as $pet) { |
235
|
1 |
|
$collectedPets[] = $this->preparePetValueObject($pet); |
236
|
1 |
|
} |
237
|
|
|
|
238
|
1 |
|
$pets = new PetsValueObject( |
239
|
1 |
|
$responseObject->pets->numCollected, |
240
|
1 |
|
$responseObject->pets->numNotCollected, |
241
|
|
|
$collectedPets |
242
|
1 |
|
); |
243
|
|
|
|
244
|
1 |
|
return $pets; |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* Data about the current battle pet slots on this characters account |
249
|
|
|
* |
250
|
|
|
* @return PetSlotsValueObject[] |
251
|
|
|
*/ |
252
|
|
View Code Duplication |
public function getPetSlots() |
|
|
|
|
253
|
|
|
{ |
254
|
|
|
$requestModel = $this->prepareRequestModel('petSlots'); |
255
|
|
|
$response = $this->requestService->doRequest($requestModel); |
256
|
|
|
$responseObject = json_decode($response); |
257
|
|
|
$petSlots = []; |
258
|
|
|
|
259
|
|
|
foreach ($responseObject->petSlots as $petSlot) { |
260
|
|
|
$petSlots[] = new PetSlotsValueObject( |
261
|
|
|
$petSlot->slot, |
262
|
|
|
$petSlot->battlePetGuid, |
263
|
|
|
$petSlot->isEmpty, |
264
|
|
|
$petSlot->isLocked, |
265
|
|
|
$petSlot->abilities |
266
|
|
|
); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
return $petSlots; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* A list of the character's professions. Does not include class professions |
274
|
|
|
* |
275
|
|
|
* @return ProfessionsValueObject |
276
|
|
|
*/ |
277
|
1 |
|
public function getProfessions() |
278
|
|
|
{ |
279
|
1 |
|
$requestModel = $this->prepareRequestModel('professions'); |
280
|
1 |
|
$response = $this->requestService->doRequest($requestModel); |
281
|
1 |
|
$responseObject = json_decode($response); |
282
|
|
|
|
283
|
1 |
|
$primaryProfessions = $this->prepareProfessionValueObject($responseObject->professions->primary); |
284
|
1 |
|
$secondaryProfessions = $this->prepareProfessionValueObject($responseObject->professions->secondary); |
285
|
|
|
|
286
|
1 |
|
$professions = new ProfessionsValueObject( |
287
|
1 |
|
$primaryProfessions, |
288
|
|
|
$secondaryProfessions |
289
|
1 |
|
); |
290
|
|
|
|
291
|
1 |
|
return $professions; |
292
|
|
|
} |
293
|
|
|
|
294
|
|
|
/** |
295
|
|
|
* A list of raids and bosses indicating raid progression and completeness |
296
|
|
|
* |
297
|
|
|
* @return ProgressionValueObject |
298
|
|
|
*/ |
299
|
|
View Code Duplication |
public function getProgression() |
|
|
|
|
300
|
|
|
{ |
301
|
|
|
$requestModel = $this->prepareRequestModel('progression'); |
302
|
|
|
$response = $this->requestService->doRequest($requestModel); |
303
|
|
|
$responseObject = json_decode($response); |
304
|
|
|
|
305
|
|
|
$raids = $this->prepareRaidValueObject($responseObject); |
306
|
|
|
|
307
|
|
|
$progression = new ProgressionValueObject( |
308
|
|
|
$raids |
309
|
|
|
); |
310
|
|
|
|
311
|
|
|
return $progression; |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
/** |
315
|
|
|
* A map of pvp information including arena team membership and rated battlegrounds information |
316
|
|
|
* |
317
|
|
|
* @return PvpValueObject |
318
|
|
|
*/ |
319
|
|
View Code Duplication |
public function getPvp() |
|
|
|
|
320
|
|
|
{ |
321
|
|
|
$requestModel = $this->prepareRequestModel('pvp'); |
322
|
|
|
$response = $this->requestService->doRequest($requestModel); |
323
|
|
|
$responseObject = json_decode($response); |
324
|
|
|
|
325
|
|
|
$brackets = $this->prepareBracketValueObject($responseObject); |
326
|
|
|
|
327
|
|
|
$progression = new PvpValueObject( |
328
|
|
|
$brackets |
329
|
|
|
); |
330
|
|
|
|
331
|
|
|
return $progression; |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* A list of quests completed by the character |
336
|
|
|
* |
337
|
|
|
* @return QuestsValueObject |
338
|
|
|
*/ |
339
|
|
View Code Duplication |
public function getQuests() |
|
|
|
|
340
|
|
|
{ |
341
|
|
|
$requestModel = $this->prepareRequestModel('quests'); |
342
|
|
|
$response = $this->requestService->doRequest($requestModel); |
343
|
|
|
$responseObject = json_decode($response); |
344
|
|
|
|
345
|
|
|
$quests = new QuestsValueObject( |
346
|
|
|
$responseObject->quests |
347
|
|
|
); |
348
|
|
|
|
349
|
|
|
return $quests; |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* A list of the factions that the character has an associated reputation with |
354
|
|
|
* |
355
|
|
|
* @return ReputationValueObject[] |
356
|
|
|
*/ |
357
|
|
View Code Duplication |
public function getReputation() |
|
|
|
|
358
|
|
|
{ |
359
|
|
|
$requestModel = $this->prepareRequestModel('reputation'); |
360
|
|
|
$response = $this->requestService->doRequest($requestModel); |
361
|
|
|
$responseObject = json_decode($response); |
362
|
|
|
$reputations = []; |
363
|
|
|
|
364
|
|
|
foreach ($responseObject->reputation as $reputation) { |
365
|
|
|
$reputations[] = new ReputationValueObject( |
366
|
|
|
$reputation->id, |
367
|
|
|
$reputation->name, |
368
|
|
|
$reputation->standing, |
369
|
|
|
$reputation->value, |
370
|
|
|
$reputation->max |
371
|
|
|
); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
return $reputations; |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
/** |
378
|
|
|
* A list of talent structures |
379
|
|
|
* |
380
|
|
|
* @return TalentsValueObject[] |
381
|
|
|
*/ |
382
|
|
|
public function getTalents() |
383
|
|
|
{ |
384
|
|
|
$requestModel = $this->prepareRequestModel('talents'); |
385
|
|
|
$response = $this->requestService->doRequest($requestModel); |
386
|
|
|
$responseObject = json_decode($response); |
387
|
|
|
$talents = []; |
388
|
|
|
|
389
|
|
|
foreach ($responseObject->talents as $talent) { |
390
|
|
|
if (empty($talent->calcSpec)) { |
391
|
|
|
continue; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
$selected = false; |
395
|
|
|
if (isset($talent->selected)) { |
396
|
|
|
$selected = true; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
$talentsValueObject = $this->prepareTalentsValueObject($talent); |
400
|
|
|
$specValueObject = $this->prepareSpecValueObject($talent->spec); |
401
|
|
|
|
402
|
|
|
$talents[] = new TalentValueObject( |
403
|
|
|
$selected, |
404
|
|
|
$talentsValueObject, |
405
|
|
|
$specValueObject, |
406
|
|
|
$talent->calcTalent, |
407
|
|
|
$talent->calcSpec |
408
|
|
|
); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
return $talents; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* A list of the titles obtained by the character including the currently selected title |
416
|
|
|
* |
417
|
|
|
* @return ReputationValueObject[] |
418
|
|
|
*/ |
419
|
|
|
public function getTitles() |
420
|
|
|
{ |
421
|
|
|
$requestModel = $this->prepareRequestModel('titles'); |
422
|
|
|
$response = $this->requestService->doRequest($requestModel); |
423
|
|
|
$responseObject = json_decode($response); |
424
|
|
|
$titles = []; |
425
|
|
|
|
426
|
|
|
foreach ($responseObject->titles as $title) { |
427
|
|
|
$titles[] = new TitleValueObject( |
428
|
|
|
$title->id, |
429
|
|
|
$title->name |
430
|
|
|
); |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
return $titles; |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/** |
437
|
|
|
* @param string $addition |
438
|
|
|
* @return RequestModel |
439
|
|
|
*/ |
440
|
8 |
|
private function prepareRequestModel($addition = '') |
441
|
|
|
{ |
442
|
8 |
|
return new RequestModel( |
443
|
8 |
|
$this->authenticationModel->getRegion(), |
444
|
8 |
|
$this->authenticationModel->getApiKey(), |
445
|
8 |
|
$this->authenticationModel->getLocale(), |
446
|
8 |
|
[$this->realm, $this->charName], |
447
|
8 |
|
'character', |
448
|
8 |
|
Franchises::WORLD_OF_WARCRAFT, |
449
|
|
|
$addition |
450
|
8 |
|
); |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* @param \StdClass $spec |
455
|
|
|
* @return HunterPetSpecValueObject |
456
|
|
|
*/ |
457
|
1 |
|
private function prepareHunterPetSpecValueObject(\StdClass $spec) |
458
|
|
|
{ |
459
|
1 |
|
return new HunterPetSpecValueObject( |
460
|
1 |
|
$spec->name, |
461
|
1 |
|
$spec->role, |
462
|
1 |
|
$spec->backgroundImage, |
463
|
1 |
|
$spec->icon, |
464
|
1 |
|
$spec->description, |
465
|
1 |
|
$spec->order |
466
|
1 |
|
); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* @param array $professions |
471
|
|
|
* |
472
|
|
|
* @return array |
473
|
|
|
*/ |
474
|
1 |
|
private function prepareProfessionValueObject($professions) { |
475
|
1 |
|
$characterProfessions = []; |
476
|
|
|
|
477
|
1 |
|
foreach ($professions as $profession) { |
478
|
1 |
|
$characterProfessions[] = new ProfessionValueObject( |
479
|
1 |
|
$profession->id, |
480
|
1 |
|
$profession->name, |
481
|
1 |
|
$profession->icon, |
482
|
1 |
|
$profession->rank, |
483
|
1 |
|
$profession->max, |
484
|
1 |
|
$profession->recipes |
485
|
1 |
|
); |
486
|
1 |
|
} |
487
|
|
|
|
488
|
1 |
|
return $characterProfessions; |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
/** |
492
|
|
|
* @param \StdClass $emblem |
493
|
|
|
* @return EmblemValueObject |
494
|
|
|
*/ |
495
|
1 |
|
private function prepareEmblem($emblem) |
496
|
|
|
{ |
497
|
1 |
|
return new EmblemValueObject ( |
498
|
1 |
|
$emblem->icon, |
499
|
1 |
|
$emblem->iconColor, |
500
|
1 |
|
$emblem->iconColorId, |
501
|
1 |
|
$emblem->border, |
502
|
1 |
|
$emblem->borderColor, |
503
|
1 |
|
$emblem->borderColorId, |
504
|
1 |
|
$emblem->backgroundColor, |
505
|
1 |
|
$emblem->backgroundColorId |
506
|
1 |
|
); |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
/** |
510
|
|
|
* @param \StdClass $mount |
511
|
|
|
* @return MountValueObject |
512
|
|
|
*/ |
513
|
1 |
|
private function prepareMountValueObject(\StdClass $mount) |
514
|
|
|
{ |
515
|
1 |
|
return new MountValueObject( |
516
|
1 |
|
$mount->name, |
517
|
1 |
|
$mount->spellId, |
518
|
1 |
|
$mount->creatureId, |
519
|
1 |
|
$mount->itemId, |
520
|
1 |
|
$mount->qualityId, |
521
|
1 |
|
$mount->icon, |
522
|
1 |
|
$mount->isGround, |
523
|
1 |
|
$mount->isFlying, |
524
|
1 |
|
$mount->isAquatic, |
525
|
1 |
|
$mount->isJumping |
526
|
1 |
|
); |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* @param \StdClass $responseObject |
531
|
|
|
* @return HunterPetValueObject[] |
532
|
|
|
*/ |
533
|
1 |
|
private function prepareHunterPets(\StdClass $responseObject) |
534
|
|
|
{ |
535
|
1 |
|
$hunterPets = []; |
536
|
1 |
|
foreach ($responseObject->hunterPets as $hunterPet) { |
537
|
1 |
|
$hunterPetSpecValueObject = null; |
538
|
1 |
|
if (isset($hunterPet->spec)) { |
539
|
1 |
|
$hunterPetSpecValueObject = $this->prepareHunterPetSpecValueObject($hunterPet->spec); |
540
|
1 |
|
} |
541
|
|
|
|
542
|
1 |
|
$hunterPets[] = new HunterPetValueObject( |
543
|
1 |
|
$hunterPet->name, |
544
|
1 |
|
$hunterPet->creature, |
545
|
1 |
|
$hunterPet->slot, |
546
|
1 |
|
$hunterPet->calcSpec, |
547
|
1 |
|
$hunterPet->familyId, |
548
|
1 |
|
$hunterPet->familyName, |
549
|
|
|
$hunterPetSpecValueObject |
550
|
1 |
|
); |
551
|
1 |
|
} |
552
|
|
|
|
553
|
1 |
|
return $hunterPets; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* @param \StdClass $pet |
558
|
|
|
* @return PetValueObject |
559
|
|
|
*/ |
560
|
1 |
|
private function preparePetValueObject($pet) |
561
|
|
|
{ |
562
|
1 |
|
$petStatValueObject = $this->preparePetStatsValueObject($pet->stats); |
563
|
|
|
|
564
|
1 |
|
return new PetValueObject( |
565
|
1 |
|
$pet->name, |
566
|
1 |
|
$pet->spellId, |
567
|
1 |
|
$pet->creatureId, |
568
|
1 |
|
$pet->itemId, |
569
|
1 |
|
$pet->qualityId, |
570
|
1 |
|
$pet->icon, |
571
|
1 |
|
$petStatValueObject, |
572
|
1 |
|
$pet->battlePetGuid, |
573
|
1 |
|
$pet->isFavorite, |
574
|
1 |
|
$pet->isFirstAbilitySlotSelected, |
575
|
1 |
|
$pet->isSecondAbilitySlotSelected, |
576
|
1 |
|
$pet->isThirdAbilitySlotSelected, |
577
|
1 |
|
$pet->creatureName, |
578
|
1 |
|
$pet->canBattle |
579
|
1 |
|
); |
580
|
|
|
} |
581
|
|
|
|
582
|
|
|
/** |
583
|
|
|
* @param \StdClass $stats |
584
|
|
|
* @return PetStatValueObject |
585
|
|
|
*/ |
586
|
1 |
|
private function preparePetStatsValueObject($stats) |
587
|
|
|
{ |
588
|
1 |
|
return new PetStatValueObject( |
589
|
1 |
|
$stats->speciesId, |
590
|
1 |
|
$stats->breedId, |
591
|
1 |
|
$stats->petQualityId, |
592
|
1 |
|
$stats->level, |
593
|
1 |
|
$stats->health, |
594
|
1 |
|
$stats->power, |
595
|
1 |
|
$stats->speed |
596
|
1 |
|
); |
597
|
|
|
} |
598
|
|
|
|
599
|
|
|
/** |
600
|
|
|
* @param \StdClass $raid |
601
|
|
|
* @return BossValueObject[] |
602
|
|
|
*/ |
603
|
|
|
private function prepareBossValueObject($raid) |
604
|
|
|
{ |
605
|
|
|
$bosses = []; |
606
|
|
|
foreach ($raid->bosses as $boss) { |
607
|
|
|
$bosses[] = new BossValueObject( |
608
|
|
|
$boss->id, |
609
|
|
|
$boss->name, |
610
|
|
|
$boss->lfrKills, |
611
|
|
|
$boss->lfrTimestamp, |
612
|
|
|
$boss->normalKills, |
613
|
|
|
$boss->normalTimestamp, |
614
|
|
|
$boss->heroicKills, |
615
|
|
|
$boss->heroicTimestamp, |
616
|
|
|
$boss->mythicKills, |
617
|
|
|
$boss->mythicTimestamp |
618
|
|
|
); |
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
return $bosses; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* @param \StdClass $responseObject |
626
|
|
|
* @return RaidValueObject[] |
627
|
|
|
*/ |
628
|
|
|
private function prepareRaidValueObject($responseObject) |
629
|
|
|
{ |
630
|
|
|
$raids = []; |
631
|
|
|
|
632
|
|
|
foreach ($responseObject->progression->raids as $raid) { |
633
|
|
|
$bosses = $this->prepareBossValueObject($raid); |
634
|
|
|
|
635
|
|
|
$raids[] = new RaidValueObject( |
636
|
|
|
$raid->name, |
637
|
|
|
$raid->lfr, |
638
|
|
|
$raid->normal, |
639
|
|
|
$raid->heroic, |
640
|
|
|
$raid->mythic, |
641
|
|
|
$raid->id, |
642
|
|
|
$bosses |
643
|
|
|
); |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
return $raids; |
647
|
|
|
} |
648
|
|
|
|
649
|
|
|
/** |
650
|
|
|
* @param \StdClass $responseObject |
651
|
|
|
* @return BracketValueObject[] |
652
|
|
|
*/ |
653
|
|
|
private function prepareBracketValueObject($responseObject) |
654
|
|
|
{ |
655
|
|
|
$brackets = []; |
656
|
|
|
|
657
|
|
|
foreach ($responseObject->pvp->brackets as $bracket) { |
658
|
|
|
$brackets[] = new BracketValueObject( |
659
|
|
|
$bracket->slug, |
660
|
|
|
$bracket->rating, |
661
|
|
|
$bracket->weeklyPlayed, |
662
|
|
|
$bracket->weeklyWon, |
663
|
|
|
$bracket->weeklyLost, |
664
|
|
|
$bracket->seasonPlayed, |
665
|
|
|
$bracket->seasonWon, |
666
|
|
|
$bracket->seasonLost |
667
|
|
|
); |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
return $brackets; |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
/** |
674
|
|
|
* @param $talent |
675
|
|
|
* @return TalentsValueObject[] |
676
|
|
|
*/ |
677
|
|
|
private function prepareTalentsValueObject($talent) |
678
|
|
|
{ |
679
|
|
|
$talents = []; |
680
|
|
|
foreach ($talent->talents as $talent) { |
681
|
|
|
$cooldown = ""; |
682
|
|
|
if (isset($talent->spell->cooldown)) { |
683
|
|
|
$cooldown = $talent->spell->cooldown; |
684
|
|
|
} |
685
|
|
|
|
686
|
|
|
$spell = new SpellValueObject( |
687
|
|
|
$talent->spell->id, |
688
|
|
|
$talent->spell->name, |
689
|
|
|
$talent->spell->icon, |
690
|
|
|
$talent->spell->description, |
691
|
|
|
$talent->spell->castTime, |
692
|
|
|
$cooldown |
693
|
|
|
); |
694
|
|
|
|
695
|
|
|
$spec = $this->prepareSpecValueObject($talent->spec); |
696
|
|
|
|
697
|
|
|
$talents[] = new TalentsValueObject( |
698
|
|
|
$talent->tier, |
699
|
|
|
$talent->column, |
700
|
|
|
$spell, |
701
|
|
|
$spec |
702
|
|
|
); |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
return $talents; |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
/** |
709
|
|
|
* @param \StdClass $spec |
710
|
|
|
* @return SpecValueObject |
711
|
|
|
*/ |
712
|
|
|
private function prepareSpecValueObject($spec) |
713
|
|
|
{ |
714
|
|
|
return new SpecValueObject( |
715
|
|
|
$spec->name, |
716
|
|
|
$spec->role, |
717
|
|
|
$spec->backgroundImage, |
718
|
|
|
$spec->icon, |
719
|
|
|
$spec->description, |
720
|
|
|
$spec->order |
721
|
|
|
); |
722
|
|
|
} |
723
|
|
|
} |
724
|
|
|
|
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.