Passed
Push — master ( b9fa94...9233ac )
by Willy
01:57
created

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