Lines 83.33% 5 / 6
Methods 50.00% 1 / 2
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 5 / 5 100.00% 1 / 1 4
 getPlatform 0.00% 0 / 1 0.00% 0 / 1 2
10final readonly class SelectConfig extends ExposedEntityConfig
11{
12    /**
13     * @param list<string> $options
14     * @throws ExposureException
15     */
16    public function __construct(
17        #[ListOf('string')]
18        public array $options,
19        ?string $name = null,
20        ?string $icon = null,
21        ?EntityCategory $entityCategory = null,
22        bool $enabledByDefault = true,
23    ) {
24        parent::__construct($name, $icon, $entityCategory, $enabledByDefault);
25
26        if ($options === []) {
27            throw ExposureException::configInvalid('A select needs at least one option.');
28        }
29
30        if (\in_array('', $options, true) || \count(array_unique($options)) !== \count($options)) {
31            throw ExposureException::configInvalid('The select options must be distinct and not empty.');
32        }
33    }
34
35    public function getPlatform(): ExposedPlatform
36    {
37        return ExposedPlatform::Select;
38    }
39}