HunterPetService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 45
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareHunterPets() 0 22 3
A prepareHunterPetSpecValueObject() 0 11 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
    public function prepareHunterPets(\StdClass $responseObject)
20
    {
21
        $hunterPets = [];
22
        foreach ($responseObject->hunterPets as $hunterPet) {
23
            $hunterPetSpecValueObject = null;
24
            if (isset($hunterPet->spec)) {
25
                $hunterPetSpecValueObject = $this->prepareHunterPetSpecValueObject($hunterPet->spec);
26
            }
27
28
            $hunterPets[] = new HunterPetValueObject(
29
                $hunterPet->name,
30
                $hunterPet->creature,
31
                $hunterPet->slot,
32
                $hunterPet->calcSpec,
33
                $hunterPet->familyId,
34
                $hunterPet->familyName,
35
                $hunterPetSpecValueObject
36
            );
37
        }
38
39
        return $hunterPets;
40
    }
41
42
    /**
43
     * @param \StdClass $spec
44
     * @return SpecValueObject
45
     */
46
    private function prepareHunterPetSpecValueObject(\StdClass $spec)
47
    {
48
        return new SpecValueObject(
49
            $spec->name,
50
            $spec->role,
51
            $spec->backgroundImage,
52
            $spec->icon,
53
            $spec->description,
54
            $spec->order
55
        );
56
    }
57
}
58