phonenumberHelper->isPhonenumberValidationConfigured()) { $this->logger->debug('[phonenumber] skipping validation due to not configured helper'); return; } if (null === $value) { return; } switch ($constraint->type) { case 'landline': $isValid = $this->phonenumberHelper->isValidPhonenumberLandOrVoip($value); $message = $constraint->notLandlineMessage; break; case 'mobile': $isValid = $this->phonenumberHelper->isValidPhonenumberMobile($value); $message = $constraint->notMobileMessage; break; case 'any': $isValid = $this->phonenumberHelper->isValidPhonenumberAny($value); $message = $constraint->notValidMessage; break; default: throw new LogicException(sprintf("This type '%s' is not implemented. " . "Possible values are 'mobile', 'landline' or 'any'", $constraint->type)); } if (false === $isValid) { $this->context->addViolation($message, ['%phonenumber%' => $value, '%formatted%' => $this->phonenumberHelper->format($value)]); } } }