DiceHydrator::hydrate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 1
rs 10
c 0
b 0
f 0
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