Conditions | 4 |
Paths | 4 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
26 | public function validate($value, Constraint $constraint) |
||
27 | { |
||
28 | if (!$constraint instanceof IsExtensionAllowed) { |
||
29 | throw new UnexpectedTypeException($constraint, IsExtensionAllowed::class); |
||
30 | } |
||
31 | |||
32 | if (!$value instanceof UploadedFile) { |
||
33 | return; |
||
34 | } |
||
35 | |||
36 | if (!$this->mediaManager->isExtensionAllowed($value)) { |
||
37 | $this->context->buildViolation($this->translator->trans($constraint->notAllowedMessage)) |
||
38 | ->setCode(IsExtensionAllowed::NOT_ALLOWED) |
||
39 | ->addViolation(); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 |