Total Complexity | 9 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class ServerVariable implements ValueObjectInterface |
||
17 | { |
||
18 | use CompositeValueObjectWithExtension; |
||
|
|||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $default; |
||
24 | |||
25 | /** |
||
26 | * @var string|null |
||
27 | */ |
||
28 | private $description; |
||
29 | |||
30 | /** |
||
31 | * @var StringList|null |
||
32 | */ |
||
33 | private $enums = null; |
||
34 | |||
35 | public function __construct(string $default, ?string $description, string... $enums) |
||
44 | } |
||
45 | |||
46 | protected function validateProperties(): void |
||
47 | { |
||
48 | if (!empty($this->enums) && !in_array($this->default, $this->enums->toNative(), true)) { |
||
49 | throw new DefaultValueNotInEnum($this->default, ...$this->enums); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | public function getDefault(): string |
||
54 | { |
||
55 | return $this->default; |
||
56 | } |
||
57 | |||
58 | public function getDescription(): ?string |
||
59 | { |
||
60 | return $this->description; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @return string[]|null |
||
65 | */ |
||
66 | public function getEnums(): ?array |
||
69 | } |
||
70 | } |