EntryValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PanicLabCore\Services\Validators;
6
7
use Webmozart\Assert\Assert;
8
9
class EntryValidator implements ValidatorInterface
10
{
11
    /** @var string[] */
12
    private $entryColors;
13
14 19
    public function __construct(array $entryColors)
15
    {
16 19
        $this->entryColors = $entryColors;
17 19
    }
18
19 14
    public function validate(array $tile): void
20
    {
21 14
        Assert::keyExists($tile, 'additional');
22
23 13
        $additional = $tile['additional'];
24
25 13
        Assert::keyExists($additional, 'color');
26 12
        Assert::oneOf($additional['color'], $this->entryColors);
27 11
    }
28
}
29