Passed
Push — master ( 52dd57...a4c9fa )
by Willy
02:14
created

prepareHunterPetSpecValueObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\HunterPet\Service;
4
5
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\HunterPet\Model\HunterPetValueObject;
6
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Shared\Model\SpecValueObject;
7
8
/**
9
 * @author  Willy Reiche
10
 * @since   2017-08-28
11
 * @version 1.0
12
 */
13
class HunterPetService
14
{
15
    /**
16
     * @param \StdClass $responseObject
17
     * @return HunterPetValueObject[]
18
     */
19 1
    public function prepareHunterPets(\StdClass $responseObject)
20
    {
21 1
        $hunterPets = [];
22 1
        foreach ($responseObject->hunterPets as $hunterPet) {
23 1
            $hunterPetSpecValueObject = null;
24 1
            if (isset($hunterPet->spec)) {
25 1
                $hunterPetSpecValueObject = $this->prepareHunterPetSpecValueObject($hunterPet->spec);
26 1
            }
27
28 1
            $hunterPets[] = new HunterPetValueObject(
29 1
                $hunterPet->name,
30 1
                $hunterPet->creature,
31 1
                $hunterPet->slot,
32 1
                $hunterPet->calcSpec,
33 1
                $hunterPet->familyId,
34 1
                $hunterPet->familyName,
35
                $hunterPetSpecValueObject
36 1
            );
37 1
        }
38
39 1
        return $hunterPets;
40
    }
41
42
    /**
43
     * @param \StdClass $spec
44
     * @return SpecValueObject
45
     */
46 1
    private function prepareHunterPetSpecValueObject(\StdClass $spec)
47
    {
48 1
        return new SpecValueObject(
49 1
            $spec->name,
50 1
            $spec->role,
51 1
            $spec->backgroundImage,
52 1
            $spec->icon,
53 1
            $spec->description,
54 1
            $spec->order
55 1
        );
56
    }
57
}
58