| Conditions | 5 |
| Paths | 9 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | public function validate(mixed $value, Constraint $constraint): void |
||
| 15 | { |
||
| 16 | if (!$value instanceof AdminResource) { |
||
| 17 | throw new UnexpectedTypeException($value, AdminResource::class); |
||
| 18 | } |
||
| 19 | |||
| 20 | if (!$value->getName()) { |
||
| 21 | $this->context->addViolation('The admin has an empty name'); |
||
| 22 | } |
||
| 23 | |||
| 24 | if (!$value->getTitle()) { |
||
| 25 | $this->context->addViolation('The admin has an empty title'); |
||
| 26 | } |
||
| 27 | |||
| 28 | if (!class_exists($value->getDataClass())) { |
||
|
|
|||
| 29 | $this->context->addViolation(sprintf( |
||
| 30 | 'The admin "%s" has an invalid data class "%s"', |
||
| 31 | $value->getName(), |
||
| 32 | $value->getDataClass(), |
||
| 33 | )); |
||
| 37 |