Passed
Push — master ( 86b291...5e082c )
by Willy
02:08
created

CharacterProfileApi::getItems()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 31
ccs 0
cts 27
cp 0
rs 8.8571
cc 1
eloc 26
nc 1
nop 0
crap 2
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\Feed\FeedObjectFactory;
14
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\GuildValueObject;
15
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\HunterPet\HunterPetSpecValueObject;
16
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\HunterPet\HunterPetValueObject;
17
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Item\ItemValueObject;
18
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Mount\MountsValueObject;
19
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Mount\MountValueObject;
20
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pet\PetStatValueObject;
21
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pet\PetsValueObject;
22
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pet\PetValueObject;
23
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\PetSlotsValueObject;
24
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Profession\ProfessionsValueObject;
25
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Profession\ProfessionValueObject;
26
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Progression\BossValueObject;
27
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Progression\ProgressionValueObject;
28
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Progression\RaidValueObject;
29
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pvp\BracketValueObject;
30
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Pvp\PvpValueObject;
31
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\QuestsValueObject;
32
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\ReputationValueObject;
33
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Talent\SpecValueObject;
34
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Talent\TalentsValueObject;
35
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\Talent\TalentValueObject;
36
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Model\TitleValueObject;
37
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Service\Item\ItemService;
38
use Kubinashi\BattlenetApi\WorldOfWarcraft\Model\SpellValueObject;
39
40
/**
41
 * @author  Willy Reiche
42
 * @since   2017-07-19
43
 * @version 1.0
44
 */
45
class CharacterProfileApi{
46
    /**
47
     * @var AuthenticationModel
48
     */
49
    private $authenticationModel;
50
51
    /**
52
     * @var RequestService
53
     */
54
    private $requestService;
55
56
    /**
57
     * @var string
58
     */
59
    private $charName;
60
61
    /**
62
     * @var string
63
     */
64
    private $realm;
65
66
    /**
67
     * @param AuthenticationModel $authenticationModel
68
     * @param RequestService $requestService
69
     * @param string $charName
70
     * @param string $realm
71
     */
72 9
    public function __construct(
73
        AuthenticationModel $authenticationModel,
74
        RequestService $requestService,
75
        $charName,
76
        $realm
77
    ) {
78 9
        $this->requestService = $requestService;
79 9
        $this->authenticationModel = $authenticationModel;
80 9
        $this->charName = $charName;
81 9
        $this->realm = $realm;
82 9
    }
83
84
    /**
85
     * The basic character data
86
     *
87
     * @return CharacterProfileValueObject
88
     */
89 1
    public function getCharacterProfile()
90
    {
91 1
        $requestModel = $this->prepareRequestModel();
92 1
        $response = $this->requestService->doRequest($requestModel);
93 1
        $responseObject = json_decode($response);
94
95 1
        $characterProfile = new CharacterProfileValueObject(
96 1
            $responseObject->lastModified,
97 1
            $responseObject->name,
98 1
            $responseObject->realm,
99 1
            $responseObject->battlegroup,
100 1
            $responseObject->class,
101 1
            $responseObject->race,
102 1
            $responseObject->gender,
103 1
            $responseObject->level,
104 1
            $responseObject->achievementPoints,
105 1
            $responseObject->thumbnail,
106 1
            $responseObject->calcClass,
107 1
            $responseObject->faction,
108 1
            $responseObject->totalHonorableKills
109 1
        );
110
111 1
        return $characterProfile;
112
    }
113
114
    /**
115
     * A map of achievement data including completion timestamps and criteria information
116
     *
117
     * @return AchievementsValueObject
118
     */
119 1
    public function getAchievements()
120
    {
121 1
        $requestModel = $this->prepareRequestModel('achievements');
122 1
        $response = $this->requestService->doRequest($requestModel);
123 1
        $responseObject = json_decode($response);
124
125 1
        $achievements = new AchievementsValueObject(
126 1
            $responseObject->achievements->achievementsCompleted,
127 1
            $responseObject->achievements->achievementsCompletedTimestamp,
128 1
            $responseObject->achievements->criteria,
129 1
            $responseObject->achievements->criteriaQuantity,
130 1
            $responseObject->achievements->criteriaTimestamp,
131 1
            $responseObject->achievements->criteriaCreated
132 1
        );
133
134 1
        return $achievements;
135
    }
136
137
    /**
138
     * A map of a character's appearance settings such as which face texture they've selected and whether or not a healm is visible
139
     *
140
     * @return AppearanceValueObject
141
     */
142 1
    public function getAppearance()
143
    {
144 1
        $requestModel = $this->prepareRequestModel('appearance');
145 1
        $response = $this->requestService->doRequest($requestModel);
146 1
        $responseObject = json_decode($response);
147
148 1
        $appearance = new AppearanceValueObject(
149 1
            $responseObject->appearance->faceVariation,
150 1
            $responseObject->appearance->skinColor,
151 1
            $responseObject->appearance->hairVariation,
152 1
            $responseObject->appearance->hairColor,
153 1
            $responseObject->appearance->featureVariation,
154 1
            $responseObject->appearance->showHelm,
155 1
            $responseObject->appearance->showCloak,
156 1
            $responseObject->appearance->customDisplayOptions
157 1
        );
158
159 1
        return $appearance;
160
    }
161
162
    /**
163
     * The activity feed of the character
164
     * Based on the type you get a different Object to access
165
     * - Achievement = FeedAchievementValueObject
166
     * - Bosskill = FeedBosskillValueObject
167
     * - Loot = FeedLootValueObject
168
     *
169
     * @return array
170
     */
171 View Code Duplication
    public function getFeed()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
172
    {
173
        $requestModel = $this->prepareRequestModel('feed');
174
        $response = $this->requestService->doRequest($requestModel);
175
        $responseObject = json_decode($response);
176
177
        $feedObjectFactory = new FeedObjectFactory();
178
        $feedObj = [];
179
180
        foreach ($responseObject->feed as $feed) {
181
            $feedObj[] = $feedObjectFactory->getFeedObject($feed);
182
        }
183
184
        return $feedObj;
185
    }
186
187
    /**
188
     * A summary of the guild that the character belongs to
189
     *
190
     * @return GuildValueObject
191
     */
192 1
    public function getGuild()
193
    {
194 1
        $requestModel = $this->prepareRequestModel('guild');
195 1
        $response = $this->requestService->doRequest($requestModel);
196 1
        $responseObject = json_decode($response);
197
198 1
        $emblemValueObject = $this->prepareEmblem($responseObject->guild->emblem);
199
200 1
        $guild = new GuildValueObject(
201 1
            $responseObject->guild->name,
202 1
            $responseObject->guild->realm,
203 1
            $responseObject->guild->battlegroup,
204 1
            $responseObject->guild->members,
205
            $emblemValueObject
206 1
        );
207
208 1
        return $guild;
209
    }
210
211
    /**
212
     * A list of all of the combat pets obtained by the character
213
     *
214
     * @return HunterPetValueObject[]
215
     */
216 1
    public function getHunterPets()
217
    {
218 1
        $requestModel = $this->prepareRequestModel('hunterPets');
219 1
        $response = $this->requestService->doRequest($requestModel);
220 1
        $responseObject = json_decode($response);
221
222 1
        return $this->prepareHunterPets($responseObject);
223
    }
224
225
    /**
226
     * A list of items equipped by the character.
227
     * Use of this field will also include the average item level and average item level equipped for the character.
228
     *
229
     * @return ItemValueObject
230
     */
231
    public function getItems()
232
    {
233
        $requestModel = $this->prepareRequestModel('items');
234
        $response = $this->requestService->doRequest($requestModel);
235
        $responseObject = json_decode($response);
236
        $itemService = new ItemService();
237
238
        $items = new ItemValueObject(
239
            $responseObject->items->averageItemLevel,
240
            $responseObject->items->averageItemLevelEquipped,
241
            $itemService->getStandardItemValueObject($responseObject->items->head),
242
            $itemService->getStandardItemValueObject($responseObject->items->neck),
243
            $itemService->getStandardItemValueObject($responseObject->items->shoulder),
244
            $itemService->getStandardItemValueObject($responseObject->items->back),
245
            $itemService->getStandardItemValueObject($responseObject->items->chest),
246
            $itemService->getStandardItemValueObject($responseObject->items->shirt),
247
            $itemService->getStandardItemValueObject($responseObject->items->wrist),
248
            $itemService->getStandardItemValueObject($responseObject->items->hands),
249
            $itemService->getStandardItemValueObject($responseObject->items->waist),
250
            $itemService->getStandardItemValueObject($responseObject->items->legs),
251
            $itemService->getStandardItemValueObject($responseObject->items->feet),
252
            $itemService->getStandardItemValueObject($responseObject->items->finger1),
253
            $itemService->getStandardItemValueObject($responseObject->items->finger2),
254
            $itemService->getStandardItemValueObject($responseObject->items->trinket1),
255
            $itemService->getStandardItemValueObject($responseObject->items->trinket2),
256
            $itemService->getWeaponItemValueObject($responseObject->items->mainHand),
257
            $itemService->getWeaponItemValueObject($responseObject->items->offHand)
258
        );
259
260
        return $items;
261
    }
262
263
    /**
264
     * A list of all of the mounts obtained by the character
265
     *
266
     * @return MountsValueObject
267
     */
268 1 View Code Duplication
    public function getMounts()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
269
    {
270 1
        $requestModel = $this->prepareRequestModel('mounts');
271 1
        $response = $this->requestService->doRequest($requestModel);
272 1
        $responseObject = json_decode($response);
273
274 1
        $collectedMounts = [];
275 1
        foreach ($responseObject->mounts->collected as $mount) {
276 1
            $collectedMounts[] = $this->prepareMountValueObject($mount);
277 1
        }
278
279 1
        $mounts = new MountsValueObject(
280 1
            $responseObject->mounts->numCollected,
281 1
            $responseObject->mounts->numNotCollected,
282
            $collectedMounts
283 1
        );
284
285 1
        return $mounts;
286
    }
287
288
    /**
289
     * A list of the battle pets obtained by the character
290
     *
291
     * @return PetsValueObject
292
     */
293 1 View Code Duplication
    public function getPets()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
294
    {
295 1
        $requestModel = $this->prepareRequestModel('pets');
296 1
        $response = $this->requestService->doRequest($requestModel);
297 1
        $responseObject = json_decode($response);
298
299 1
        $collectedPets = [];
300 1
        foreach ($responseObject->pets->collected as $pet) {
301 1
            $collectedPets[] = $this->preparePetValueObject($pet);
302 1
        }
303
304 1
        $pets = new PetsValueObject(
305 1
            $responseObject->pets->numCollected,
306 1
            $responseObject->pets->numNotCollected,
307
            $collectedPets
308 1
        );
309
310 1
        return $pets;
311
    }
312
313
    /**
314
     * Data about the current battle pet slots on this characters account
315
     *
316
     * @return PetSlotsValueObject[]
317
     */
318 View Code Duplication
    public function getPetSlots()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
319
    {
320
        $requestModel = $this->prepareRequestModel('petSlots');
321
        $response = $this->requestService->doRequest($requestModel);
322
        $responseObject = json_decode($response);
323
        $petSlots = [];
324
325
        foreach ($responseObject->petSlots as $petSlot) {
326
            $petSlots[] = new PetSlotsValueObject(
327
                $petSlot->slot,
328
                $petSlot->battlePetGuid,
329
                $petSlot->isEmpty,
330
                $petSlot->isLocked,
331
                $petSlot->abilities
332
            );
333
        }
334
335
        return $petSlots;
336
    }
337
338
    /**
339
     * A list of the character's professions. Does not include class professions
340
     *
341
     * @return ProfessionsValueObject
342
     */
343 1
    public function getProfessions()
344
    {
345 1
        $requestModel = $this->prepareRequestModel('professions');
346 1
        $response = $this->requestService->doRequest($requestModel);
347 1
        $responseObject = json_decode($response);
348
349 1
        $primaryProfessions = $this->prepareProfessionValueObject($responseObject->professions->primary);
350 1
        $secondaryProfessions = $this->prepareProfessionValueObject($responseObject->professions->secondary);
351
352 1
        $professions = new ProfessionsValueObject(
353 1
            $primaryProfessions,
354
            $secondaryProfessions
355 1
        );
356
357 1
        return $professions;
358
    }
359
360
    /**
361
     * A list of raids and bosses indicating raid progression and completeness
362
     *
363
     * @return ProgressionValueObject
364
     */
365 View Code Duplication
    public function getProgression()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
366
    {
367
        $requestModel = $this->prepareRequestModel('progression');
368
        $response = $this->requestService->doRequest($requestModel);
369
        $responseObject = json_decode($response);
370
371
        $raids = $this->prepareRaidValueObject($responseObject);
372
373
        $progression = new ProgressionValueObject(
374
            $raids
375
        );
376
377
        return $progression;
378
    }
379
380
    /**
381
     * A map of pvp information including arena team membership and rated battlegrounds information
382
     *
383
     * @return PvpValueObject
384
     */
385 View Code Duplication
    public function getPvp()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
386
    {
387
        $requestModel = $this->prepareRequestModel('pvp');
388
        $response = $this->requestService->doRequest($requestModel);
389
        $responseObject = json_decode($response);
390
391
        $brackets = $this->prepareBracketValueObject($responseObject);
392
393
        $progression = new PvpValueObject(
394
            $brackets
395
        );
396
397
        return $progression;
398
    }
399
400
    /**
401
     * A list of quests completed by the character
402
     *
403
     * @return QuestsValueObject
404
     */
405 View Code Duplication
    public function getQuests()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
406
    {
407
        $requestModel = $this->prepareRequestModel('quests');
408
        $response = $this->requestService->doRequest($requestModel);
409
        $responseObject = json_decode($response);
410
411
        $quests = new QuestsValueObject(
412
            $responseObject->quests
413
        );
414
415
        return $quests;
416
    }
417
418
    /**
419
     * A list of the factions that the character has an associated reputation with
420
     *
421
     * @return ReputationValueObject[]
422
     */
423 View Code Duplication
    public function getReputation()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
424
    {
425
        $requestModel = $this->prepareRequestModel('reputation');
426
        $response = $this->requestService->doRequest($requestModel);
427
        $responseObject = json_decode($response);
428
        $reputations = [];
429
430
        foreach ($responseObject->reputation as $reputation) {
431
            $reputations[] = new ReputationValueObject(
432
                $reputation->id,
433
                $reputation->name,
434
                $reputation->standing,
435
                $reputation->value,
436
                $reputation->max
437
            );
438
        }
439
440
        return $reputations;
441
    }
442
443
    /**
444
     * A list of talent structures
445
     *
446
     * @return TalentsValueObject[]
447
     */
448
    public function getTalents()
449
    {
450
        $requestModel = $this->prepareRequestModel('talents');
451
        $response = $this->requestService->doRequest($requestModel);
452
        $responseObject = json_decode($response);
453
        $talents = [];
454
455
        foreach ($responseObject->talents as $talent) {
456
            if (empty($talent->calcSpec)) {
457
                continue;
458
            }
459
460
            $selected = false;
461
            if (isset($talent->selected)) {
462
                $selected = true;
463
            }
464
465
            $talentsValueObject = $this->prepareTalentsValueObject($talent);
466
            $specValueObject = $this->prepareSpecValueObject($talent->spec);
467
468
            $talents[] = new TalentValueObject(
469
                $selected,
470
                $talentsValueObject,
471
                $specValueObject,
472
                $talent->calcTalent,
473
                $talent->calcSpec
474
            );
475
        }
476
477
        return $talents;
478
    }
479
480
    /**
481
     * A list of the titles obtained by the character including the currently selected title
482
     *
483
     * @return ReputationValueObject[]
484
     */
485 View Code Duplication
    public function getTitles()
0 ignored issues
show
Duplication introduced by
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.

Loading history...
486
    {
487
        $requestModel = $this->prepareRequestModel('titles');
488
        $response = $this->requestService->doRequest($requestModel);
489
        $responseObject = json_decode($response);
490
        $titles = [];
491
492
        foreach ($responseObject->titles as $title) {
493
            $titles[] = new TitleValueObject(
494
                $title->id,
495
                $title->name
496
            );
497
        }
498
499
        return $titles;
500
    }
501
502
    /**
503
     * @param string $addition
504
     * @return RequestModel
505
     */
506 8
    private function prepareRequestModel($addition = '')
507
    {
508 8
        return new RequestModel(
509 8
            $this->authenticationModel->getRegion(),
510 8
            $this->authenticationModel->getApiKey(),
511 8
            $this->authenticationModel->getLocale(),
512 8
            [$this->realm, $this->charName],
513 8
            'character',
514 8
            Franchises::WORLD_OF_WARCRAFT,
515
            $addition
516 8
        );
517
    }
518
519
    /**
520
     * @param \StdClass $spec
521
     * @return HunterPetSpecValueObject
522
     */
523 1
    private function prepareHunterPetSpecValueObject(\StdClass $spec)
524
    {
525 1
        return new HunterPetSpecValueObject(
526 1
            $spec->name,
527 1
            $spec->role,
528 1
            $spec->backgroundImage,
529 1
            $spec->icon,
530 1
            $spec->description,
531 1
            $spec->order
532 1
        );
533
    }
534
535
    /**
536
     * @param array $professions
537
     *
538
     * @return array
539
     */
540 1
    private function prepareProfessionValueObject($professions) {
541 1
        $characterProfessions = [];
542
543 1
        foreach ($professions as $profession) {
544 1
            $characterProfessions[] = new ProfessionValueObject(
545 1
                $profession->id,
546 1
                $profession->name,
547 1
                $profession->icon,
548 1
                $profession->rank,
549 1
                $profession->max,
550 1
                $profession->recipes
551 1
            );
552 1
        }
553
554 1
        return $characterProfessions;
555
    }
556
557
    /**
558
     * @param \StdClass $emblem
559
     * @return EmblemValueObject
560
     */
561 1
    private function prepareEmblem($emblem)
562
    {
563 1
        return new EmblemValueObject (
564 1
            $emblem->icon,
565 1
            $emblem->iconColor,
566 1
            $emblem->iconColorId,
567 1
            $emblem->border,
568 1
            $emblem->borderColor,
569 1
            $emblem->borderColorId,
570 1
            $emblem->backgroundColor,
571 1
            $emblem->backgroundColorId
572 1
        );
573
    }
574
575
    /**
576
     * @param \StdClass $mount
577
     * @return MountValueObject
578
     */
579 1
    private function prepareMountValueObject(\StdClass $mount)
580
    {
581 1
        return new MountValueObject(
582 1
            $mount->name,
583 1
            $mount->spellId,
584 1
            $mount->creatureId,
585 1
            $mount->itemId,
586 1
            $mount->qualityId,
587 1
            $mount->icon,
588 1
            $mount->isGround,
589 1
            $mount->isFlying,
590 1
            $mount->isAquatic,
591 1
            $mount->isJumping
592 1
        );
593
    }
594
595
    /**
596
     * @param \StdClass $responseObject
597
     * @return HunterPetValueObject[]
598
     */
599 1
    private function prepareHunterPets(\StdClass $responseObject)
600
    {
601 1
        $hunterPets = [];
602 1
        foreach ($responseObject->hunterPets as $hunterPet) {
603 1
            $hunterPetSpecValueObject = null;
604 1
            if (isset($hunterPet->spec)) {
605 1
                $hunterPetSpecValueObject = $this->prepareHunterPetSpecValueObject($hunterPet->spec);
606 1
            }
607
608 1
            $hunterPets[] = new HunterPetValueObject(
609 1
                $hunterPet->name,
610 1
                $hunterPet->creature,
611 1
                $hunterPet->slot,
612 1
                $hunterPet->calcSpec,
613 1
                $hunterPet->familyId,
614 1
                $hunterPet->familyName,
615
                $hunterPetSpecValueObject
616 1
            );
617 1
        }
618
619 1
        return $hunterPets;
620
    }
621
622
    /**
623
     * @param \StdClass $pet
624
     * @return PetValueObject
625
     */
626 1
    private function preparePetValueObject($pet)
627
    {
628 1
        $petStatValueObject = $this->preparePetStatsValueObject($pet->stats);
629
630 1
        return new PetValueObject(
631 1
            $pet->name,
632 1
            $pet->spellId,
633 1
            $pet->creatureId,
634 1
            $pet->itemId,
635 1
            $pet->qualityId,
636 1
            $pet->icon,
637 1
            $petStatValueObject,
638 1
            $pet->battlePetGuid,
639 1
            $pet->isFavorite,
640 1
            $pet->isFirstAbilitySlotSelected,
641 1
            $pet->isSecondAbilitySlotSelected,
642 1
            $pet->isThirdAbilitySlotSelected,
643 1
            $pet->creatureName,
644 1
            $pet->canBattle
645 1
        );
646
    }
647
648
    /**
649
     * @param \StdClass $stats
650
     * @return PetStatValueObject
651
     */
652 1
    private function preparePetStatsValueObject($stats)
653
    {
654 1
        return new PetStatValueObject(
655 1
            $stats->speciesId,
656 1
            $stats->breedId,
657 1
            $stats->petQualityId,
658 1
            $stats->level,
659 1
            $stats->health,
660 1
            $stats->power,
661 1
            $stats->speed
662 1
        );
663
    }
664
665
    /**
666
     * @param \StdClass $raid
667
     * @return BossValueObject[]
668
     */
669
    private function prepareBossValueObject($raid)
670
    {
671
        $bosses = [];
672
        foreach ($raid->bosses as $boss) {
673
            $bosses[] = new BossValueObject(
674
                $boss->id,
675
                $boss->name,
676
                $boss->lfrKills,
677
                $boss->lfrTimestamp,
678
                $boss->normalKills,
679
                $boss->normalTimestamp,
680
                $boss->heroicKills,
681
                $boss->heroicTimestamp,
682
                $boss->mythicKills,
683
                $boss->mythicTimestamp
684
            );
685
        }
686
687
        return $bosses;
688
    }
689
690
    /**
691
     * @param \StdClass $responseObject
692
     * @return RaidValueObject[]
693
     */
694
    private function prepareRaidValueObject($responseObject)
695
    {
696
        $raids = [];
697
698
        foreach ($responseObject->progression->raids as $raid) {
699
            $bosses = $this->prepareBossValueObject($raid);
700
701
            $raids[] = new RaidValueObject(
702
                $raid->name,
703
                $raid->lfr,
704
                $raid->normal,
705
                $raid->heroic,
706
                $raid->mythic,
707
                $raid->id,
708
                $bosses
709
            );
710
        }
711
712
        return $raids;
713
    }
714
715
    /**
716
     * @param \StdClass $responseObject
717
     * @return BracketValueObject[]
718
     */
719
    private function prepareBracketValueObject($responseObject)
720
    {
721
        $brackets = [];
722
723
        foreach ($responseObject->pvp->brackets as $bracket) {
724
            $brackets[] = new BracketValueObject(
725
                $bracket->slug,
726
                $bracket->rating,
727
                $bracket->weeklyPlayed,
728
                $bracket->weeklyWon,
729
                $bracket->weeklyLost,
730
                $bracket->seasonPlayed,
731
                $bracket->seasonWon,
732
                $bracket->seasonLost
733
            );
734
        }
735
736
        return $brackets;
737
    }
738
739
    /**
740
     * @param $talent
741
     * @return TalentsValueObject[]
742
     */
743
    private function prepareTalentsValueObject($talent)
744
    {
745
        $talents = [];
746
        foreach ($talent->talents as $talent) {
747
            $cooldown = "";
748
            if (isset($talent->spell->cooldown)) {
749
                $cooldown = $talent->spell->cooldown;
750
            }
751
752
            $spell = new SpellValueObject(
753
                $talent->spell->id,
754
                $talent->spell->name,
755
                $talent->spell->icon,
756
                $talent->spell->description,
757
                $talent->spell->castTime,
758
                $cooldown
759
            );
760
761
            $spec = $this->prepareSpecValueObject($talent->spec);
762
763
            $talents[] = new TalentsValueObject(
764
                $talent->tier,
765
                $talent->column,
766
                $spell,
767
                $spec
768
            );
769
        }
770
771
        return $talents;
772
    }
773
774
    /**
775
     * @param \StdClass $spec
776
     * @return SpecValueObject
777
     */
778
    private function prepareSpecValueObject($spec)
779
    {
780
        return new SpecValueObject(
781
            $spec->name,
782
            $spec->role,
783
            $spec->backgroundImage,
784
            $spec->icon,
785
            $spec->description,
786
            $spec->order
787
        );
788
    }
789
}
790