| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function validate(mixed $value, Constraint $constraint) {# |
||
| 19 | if(!$value instanceof DateLesson) { |
||
| 20 | throw new UnexpectedTypeException($value, DateLesson::class); |
||
| 21 | } |
||
| 22 | |||
| 23 | if(!$constraint instanceof DateLessonInSection) { |
||
| 24 | throw new UnexpectedTypeException($constraint, DateLessonInSection::class); |
||
| 25 | } |
||
| 26 | |||
| 27 | $section = $this->sectionResolver->getSectionForDate($value->getDate()); |
||
|
|
|||
| 28 | |||
| 29 | if($section === null) { |
||
| 30 | $sections = $this->sectionRepository->findAll(); |
||
| 31 | |||
| 32 | $this->context |
||
| 33 | ->buildViolation($constraint->message) |
||
| 34 | ->setParameter('{{ sections }}', implode(', ', array_map(fn(Section $section) => $section->getDisplayName(), $sections))) |
||
| 35 | ->addViolation(); |
||
| 36 | } |
||
| 38 | } |