Passed
Push — master ( a55f22...56813c )
by Paweł
02:35
created

DenormalizePlayer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 17
ccs 0
cts 13
cp 0
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Infrastructure\Persistence;
6
7
use AardsGerds\Game\Build\Attribute\AttributePoints;
8
use AardsGerds\Game\Build\Attribute\Etherum;
9
use AardsGerds\Game\Build\Attribute\Health;
10
use AardsGerds\Game\Build\Attribute\Strength;
11
use AardsGerds\Game\Build\Experience;
12
use AardsGerds\Game\Build\Level;
13
use AardsGerds\Game\Build\LevelProgress;
14
use AardsGerds\Game\Build\Talent\TalentCollection;
15
use AardsGerds\Game\Build\Talent\TalentPoints;
16
use AardsGerds\Game\Inventory\Weapon\ShortSword\RustyShortSword;
17
use AardsGerds\Game\Player\Player;
18
19
final class DenormalizePlayer
20
{
21
    public function __invoke(array $data): Player
22
    {
23
        return new Player(
24
            $data['name'],
25
            new Health($data['health']),
26
            new Etherum($data['etherum']),
27
            new Strength($data['strength']),
28
            new TalentCollection([]),
29
            new RustyShortSword(),
30
            new LevelProgress(
31
                new Level($data['levelProgress']['level']),
32
                new Experience($data['levelProgress']['currentExperience']),
33
            ),
34
            new AttributePoints($data['attributePoints']),
35
            new TalentPoints($data['talentPoints']),
36
        );
37
    }
38
}
39