|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace PanicLabCore\Services\Validators; |
|
6
|
|
|
|
|
7
|
|
|
use Webmozart\Assert\Assert; |
|
8
|
|
|
|
|
9
|
|
|
class DiceValidator implements ValidatorInterface |
|
10
|
|
|
{ |
|
11
|
|
|
/** @var string[] */ |
|
12
|
|
|
private $germColors; |
|
13
|
|
|
|
|
14
|
|
|
/** @var string[] */ |
|
15
|
|
|
private $germStyles; |
|
16
|
|
|
|
|
17
|
|
|
/** @var string[] */ |
|
18
|
|
|
private $germSizes; |
|
19
|
|
|
|
|
20
|
|
|
/** @var string[] */ |
|
21
|
|
|
private $entryColors; |
|
22
|
|
|
|
|
23
|
|
|
/** @var string[] */ |
|
24
|
|
|
private $entryDirections; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param string[] $germColors |
|
28
|
|
|
* @param string[] $germStyles |
|
29
|
|
|
* @param string[] $germSizes |
|
30
|
|
|
* @param string[] $entryColors |
|
31
|
|
|
* @param string[] $entryDirections |
|
32
|
|
|
*/ |
|
33
|
14 |
|
public function __construct( |
|
34
|
|
|
array $germColors, |
|
35
|
|
|
array $germStyles, |
|
36
|
|
|
array $germSizes, |
|
37
|
|
|
array $entryColors, |
|
38
|
|
|
array $entryDirections |
|
39
|
|
|
) { |
|
40
|
14 |
|
$this->germColors = $germColors; |
|
41
|
14 |
|
$this->germStyles = $germStyles; |
|
42
|
14 |
|
$this->germSizes = $germSizes; |
|
43
|
14 |
|
$this->entryColors = $entryColors; |
|
44
|
14 |
|
$this->entryDirections = $entryDirections; |
|
45
|
14 |
|
} |
|
46
|
|
|
|
|
47
|
11 |
|
public function validate(array $diceData): void |
|
48
|
|
|
{ |
|
49
|
11 |
|
Assert::keyExists($diceData, 'germColor'); |
|
50
|
10 |
|
Assert::keyExists($diceData, 'germSize'); |
|
51
|
9 |
|
Assert::keyExists($diceData, 'germStyle'); |
|
52
|
8 |
|
Assert::keyExists($diceData, 'entryColor'); |
|
53
|
7 |
|
Assert::keyExists($diceData, 'entryDirection'); |
|
54
|
|
|
|
|
55
|
6 |
|
Assert::oneOf($diceData['germColor'], $this->germColors); |
|
56
|
5 |
|
Assert::oneOf($diceData['germSize'], $this->germSizes); |
|
57
|
4 |
|
Assert::oneOf($diceData['germStyle'], $this->germStyles); |
|
58
|
3 |
|
Assert::oneOf($diceData['entryColor'], $this->entryColors); |
|
59
|
2 |
|
Assert::oneOf($diceData['entryDirection'], $this->entryDirections); |
|
60
|
1 |
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|