DiceHydrator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 29
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 3 1
A supports() 0 3 1
A hydrate() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PanicLabCore\Services\Hydrators;
6
7
use PanicLabCore\Services\Validators\ValidatorInterface;
8
use PanicLabCore\Structs\Dice;
9
use PanicLabCore\Structs\Tile;
10
11
class DiceHydrator implements HydratorInterface
12
{
13
    /** @var ValidatorInterface */
14
    private $diceValidator;
15
16 4
    public function __construct(ValidatorInterface $diceValidator)
17
    {
18 4
        $this->diceValidator = $diceValidator;
19 4
    }
20
21 2
    public function supports(string $type): bool
22
    {
23 2
        return true;
24
    }
25
26 1
    public function hydrate(array $diceData): Tile
27
    {
28 1
        return new Dice(
29 1
            $diceData['germColor'],
30 1
            $diceData['germSize'],
31 1
            $diceData['germStyle'],
32 1
            $diceData['entryColor'],
33 1
            $diceData['entryDirection']
34
        );
35
    }
36
37 1
    public function validate(array $diceData): void
38
    {
39 1
        $this->diceValidator->validate($diceData);
40 1
    }
41
}
42