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