Passed
Push — master ( c443ba...b9fa94 )
by Willy
02:30
created

CharacterProfileApi::getStatistics()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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