| Conditions | 4 |
| Paths | 3 |
| Total Lines | 11 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4.0312 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | 12 | public function validate($value, Constraint $constraint) |
|
| 19 | { |
||
| 20 | 12 | if (!$constraint instanceof CsrfConstraint) { |
|
| 21 | throw new UnexpectedTypeException($constraint, CsrfConstraint::class); |
||
| 22 | } |
||
| 23 | |||
| 24 | 12 | if (!$value instanceof CsrfToken || !$constraint->manager->isTokenValid($value)) { |
|
| 25 | 10 | $this->context->buildViolation($constraint->message) |
|
| 26 | 10 | ->setParameter('{{ value }}', $this->formatValue($value)) |
|
| 27 | 10 | ->setCode(CsrfConstraint::INVALID_TOKEN_ERROR) |
|
| 28 | 10 | ->addViolation() |
|
| 29 | ; |
||
| 33 |