EntryValidator::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
ccs 5
cts 5
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\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