| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5.025 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 21 | public function validate($value, Constraint $constraint) |
|
| 18 | { |
||
| 19 | 21 | if (!$constraint instanceof TransformerExceptionConstraint) { |
|
| 20 | throw new UnexpectedTypeException($constraint, TransformerExceptionConstraint::class); |
||
| 21 | } |
||
| 22 | |||
| 23 | 21 | if ($constraint->validationCallback) { |
|
| 24 | 1 | if (!($constraint->validationCallback)($value, $constraint, $this->context->getRoot())) { |
|
| 25 | 1 | return; |
|
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | 21 | $this->context->buildViolation($constraint->message ?: $constraint->exception->getMessage()) |
|
| 30 | 21 | ->setCode($constraint->code) |
|
| 31 | 21 | ->setParameter('{{ value }}', $this->formatValue($value)) |
|
| 32 | 21 | ->addViolation() |
|
| 33 | ; |
||
| 36 |