class ValidatingService in International Phone 8
Same name and namespace in other branches
- 8.2 src/Helpers/ValidatingService.php \Drupal\phone_international\Helpers\ValidatingService
- 3.x src/Helpers/ValidatingService.php \Drupal\phone_international\Helpers\ValidatingService
Class ValidatingService.
Hierarchy
- class \Drupal\phone_international\Helpers\ValidatingService implements isValid
Expanded class hierarchy of ValidatingService
1 string reference to 'ValidatingService'
1 service uses ValidatingService
File
- src/
Helpers/ ValidatingService.php, line 12
Namespace
Drupal\phone_international\HelpersView source
class ValidatingService implements isValid {
/**
* Utility for international phone numbers.
*
* @param string $number
* Phone number verification and validation.
*
* @return bool
* Return number valid(TRUE) or invalid(FALSE).
*/
public function isValidNumber($number) {
$phoneUtil = PhoneNumberUtil::getInstance();
try {
$parseNumber = $phoneUtil
->parse($number);
return $phoneUtil
->isValidNumber($parseNumber);
} catch (NumberParseException $e) {
Drupal::logger('phone_international')
->debug($e);
return FALSE;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ValidatingService:: |
public | function |
Utility for international phone numbers. Overrides isValid:: |