| Conditions | 7 |
| Paths | 9 |
| Total Lines | 26 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function validate($attribute, Constraint $constraint): void |
||
| 28 | { |
||
| 29 | /** @var AttributeInterface $attribute */ |
||
| 30 | Assert::isInstanceOf($attribute, AttributeInterface::class); |
||
| 31 | Assert::isInstanceOf($constraint, ValidTextAttributeConfiguration::class); |
||
| 32 | |||
| 33 | if (TextAttributeType::TYPE !== $attribute->getType()) { |
||
| 34 | return; |
||
| 35 | } |
||
| 36 | |||
| 37 | $configuration = $attribute->getConfiguration(); |
||
| 38 | |||
| 39 | $min = null; |
||
| 40 | if (!empty($configuration['min'])) { |
||
| 41 | $min = $configuration['min']; |
||
| 42 | } |
||
| 43 | |||
| 44 | $max = null; |
||
| 45 | if (!empty($configuration['max'])) { |
||
| 46 | $max = $configuration['max']; |
||
| 47 | } |
||
| 48 | |||
| 49 | if (null !== $min && null !== $max && $min > $max) { |
||
| 50 | $this->context->addViolation($constraint->message); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 |