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

ProfessionService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 42
ccs 20
cts 20
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareProfessionsValueObject() 0 12 1
A prepareProfessionValueObject() 0 16 2
1
<?php
2
3
namespace Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Profession\Service;
4
5
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Profession\Model\ProfessionsValueObject;
6
use Kubinashi\BattlenetApi\WorldOfWarcraft\CharacterProfileApi\Profession\Model\ProfessionValueObject;
7
8
/**
9
 * @author  Willy Reiche
10
 * @since   2017-08-28
11
 * @version 1.0
12
 */
13
class ProfessionService
14
{
15
    /**
16
     * @param \StdClass $professions
17
     *
18
     * @return ProfessionsValueObject
19
     */
20 1
    public function prepareProfessionsValueObject($professions)
21
    {
22 1
        $primaryProfessions = $this->prepareProfessionValueObject($professions->primary);
23 1
        $secondaryProfessions = $this->prepareProfessionValueObject($professions->secondary);
24
25 1
        $professions = new ProfessionsValueObject(
26 1
            $primaryProfessions,
27
            $secondaryProfessions
28 1
        );
29
30 1
        return $professions;
31
    }
32
33
    /**
34
     * @param \StdClass[] $professions
35
     *
36
     * @return ProfessionValueObject[]
37
     */
38 1
    private function prepareProfessionValueObject($professions) {
39 1
        $characterProfessions = [];
40
41 1
        foreach ($professions as $profession) {
42 1
            $characterProfessions[] = new ProfessionValueObject(
43 1
                $profession->id,
44 1
                $profession->name,
45 1
                $profession->icon,
46 1
                $profession->rank,
47 1
                $profession->max,
48 1
                $profession->recipes
49 1
            );
50 1
        }
51
52 1
        return $characterProfessions;
53
    }
54
}
55