Conditions | 5 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
49 | $valid = $value instanceof $this->targetEnum |
||
50 | || $this->useKey && $this->targetEnum::isValidKey($value) |
||
51 | || $this->targetEnum::isValid($value); |
||
52 | |||
53 | return !$valid ? [$this->getMessage(), []] : \null; |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getMessage(): string |
||
60 | { |
||
61 | return \Yii::t(static::class, "Attribute [{attribute}] must be instance or be part of {$this->targetEnum}"); |
||
62 | } |
||
63 | } |
||
64 |