| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4.016 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | 11 | public function validate($value, Constraint $constraint) |
|
| 35 | { |
||
| 36 | 11 | if (!$constraint instanceof ValidPhoneNumber) { |
|
| 37 | throw new UnexpectedTypeException($constraint, ValidPhoneNumber::class); |
||
| 38 | } |
||
| 39 | |||
| 40 | 11 | if (!$value instanceof PhoneNumberValue) { |
|
| 41 | 4 | return; |
|
| 42 | } |
||
| 43 | |||
| 44 | 9 | if (!$this->formatter->isValidNumber($value)) { |
|
| 45 | 4 | $this->context->buildViolation($constraint->message) |
|
| 46 | 4 | ->setParameter('{{ value }}', $this->formatValue($value)) |
|
| 47 | 4 | ->setCode(ValidPhoneNumber::INVALID_PHONE_NUMBER_ERROR) |
|
| 48 | 4 | ->addViolation() |
|
| 49 | ; |
||
| 53 |