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 5
 getPlatform 0.00% 0 / 1 0.00% 0 / 1 2
9final readonly class TextConfig extends ExposedEntityConfig
10{
11    public const int MAX_LENGTH = 255;
12
13    /** @throws ExposureException */
14    public function __construct(
15        public int $min = 0,
16        public int $max = self::MAX_LENGTH,
17        public ?string $pattern = null,
18        public TextMode $mode = TextMode::Text,
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 ($min < 0 || $min > $max || $max > self::MAX_LENGTH) {
27            throw ExposureException::configInvalid(\sprintf('The text length limits must satisfy 0 <= min <= max <= %d.', self::MAX_LENGTH));
28        }
29
30        if ($pattern === '') {
31            throw ExposureException::configInvalid('The text pattern must not be empty; leave it null for none.');
32        }
33    }
34
35    public function getPlatform(): ExposedPlatform
36    {
37        return ExposedPlatform::Text;
38    }
39}