You are here

class ValidatingService in International Phone 8

Same name and namespace in other branches
  1. 8.2 src/Helpers/ValidatingService.php \Drupal\phone_international\Helpers\ValidatingService
  2. 3.x src/Helpers/ValidatingService.php \Drupal\phone_international\Helpers\ValidatingService

Class ValidatingService.

Hierarchy

Expanded class hierarchy of ValidatingService

1 string reference to 'ValidatingService'
phone_international.services.yml in ./phone_international.services.yml
phone_international.services.yml
1 service uses ValidatingService
phone_international.validate in ./phone_international.services.yml
Drupal\phone_international\Helpers\ValidatingService

File

src/Helpers/ValidatingService.php, line 12

Namespace

Drupal\phone_international\Helpers
View 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

Namesort descending Modifiers Type Description Overrides
ValidatingService::isValidNumber public function Utility for international phone numbers. Overrides isValid::isValidNumber