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