Total Complexity | 8 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class SchemaEnumAttribute extends SchemaAttribute |
||
11 | { |
||
12 | protected array $values; |
||
13 | |||
14 | public function __construct(Schema $schema, string $name) |
||
15 | { |
||
16 | parent::__construct($schema, $name); |
||
17 | $this->values = []; |
||
18 | } |
||
19 | |||
20 | public function values(array $values): self |
||
21 | { |
||
22 | $this->values = $values; |
||
23 | return $this; |
||
24 | } |
||
25 | |||
26 | private function matchesLoose($value) |
||
27 | { |
||
28 | return array_reduce($this->values, fn($x, $y) => $x ?? ($y == $value ? $y : null), null); |
||
29 | } |
||
30 | |||
31 | public function parseContextual($value) |
||
40 | } |
||
41 | |||
42 | private function getValuesVerbose(): string |
||
43 | { |
||
44 | return implode(', ', $this->values); |
||
45 | } |
||
46 | |||
47 | public static function from(Schema $schema, string $name): self |
||
50 | } |
||
51 | } |