示例#1
0
 /**
  * @param string $country
  *
  * @return string
  *
  * @throws Exceptions\NoValidCountryException
  */
 protected function validateCountry($country)
 {
     // Country code have to be upper-cased
     $country = strtoupper($country);
     if (strlen($country) === 2 && ctype_alpha($country) && ctype_upper($country) && in_array($country, $this->phoneUtils->getSupportedCountries()) || $country === 'AUTO') {
         return $country;
     } else {
         throw new Exceptions\NoValidCountryException('Provided country code "' . $country . '" is not valid. Provide valid country code or AUTO for automatic detection.');
     }
 }