15 public $regex =
'/^\\+(\\d+( |\\-| ?\\(|\\) ?)?)+\\d+$/';
28 $config = parent::clientConfig();
29 $mask_key = $this->number ? $this->number .
'Mask' :
'mask';
30 $example_key = $this->number ? $this->number .
'Example' :
'example';
32 foreach($this->countries as $code => $country) $config[
self::COUNTRIES][$code] =
33 \Rsi\Record::select($country,[
'callingCode',
'internationalPrefix',
'nationalPrefix']) + [
34 'mask' => $country[$mask_key],
35 'example' =>
'+' . $country[
'callingCode'] .
' ' . $country[$example_key]
41 $value = preg_replace(
'/\\D+/',
'',$value);
42 $mask_key = $this->number ? $this->number .
'Mask' :
'mask';
43 foreach($this->countries as $country)
if(preg_match(
'/^' . $country[
'callingCode'] .
'(' . ($country[$mask_key] ??
'.+') .
')$/',$value))
return true;
48 if($this->_countries ===
null){
49 $data = $this->fred->cache->fetch($this->countriesKey,$this->countriesTtl,
function(){
51 foreach(\
Rsi\Record::sort($this->fred->services->countries(),
function($a,$b){
52 return $a[$this->countryOrder] <=> $b[$this->countryOrder];
53 }) as $code => $country)
if($info = $country[
'dialling'] ??
null){
54 $data[$code] = [
'title' => $this->fred->trans->str($this->countryFormat,$country)];
55 foreach($info as $key => $value) $data[$code][lcfirst(\Rsi\Str::camel($key))] = is_array($value) ? array_shift($value) : $value;
59 $this->_countries = ($countries = array_filter((array)$this->
config(self::COUNTRIES))) ? \
Rsi\Record::select($data,$countries) : $data;