fix format number
This commit is contained in:
parent
4fd36ad820
commit
f87aebb20c
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"require": {
|
||||
"ingenerator/tokenista": "^1.1",
|
||||
"ajani/flash-message": "^2.0"
|
||||
"ajani/flash-message": "^2.0",
|
||||
"giggsey/libphonenumber-for-php": "^8.10"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace controllers\internals;
|
|||
return $result;
|
||||
}
|
||||
|
||||
$this->internal_event->create('CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_add_space($number).')');
|
||||
$this->internal_event->create('CONTACT_ADD', 'Ajout contact : '.$name.' ('.\controllers\internals\Tool::phone_format($number).')');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,11 @@ namespace controllers\internals;
|
|||
*
|
||||
* @return mixed : Si le numéro est bien un numéro de téléphone, on retourne le numéro parsé. Sinon, on retourne faux
|
||||
*/
|
||||
public static function phone_add_space($number)
|
||||
public static function phone_format($number)
|
||||
{
|
||||
return preg_replace('#(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})#', '$1 $2 $3 $4 $5', $number);
|
||||
$phone_number_util = \libphonenumber\PhoneNumberUtil::getInstance();
|
||||
$phone_number_o = $phone_number_util->parse($number, null);
|
||||
return $phone_number_util->format($phone_number_o, \libphonenumber\PhoneNumberFormat::INTERNATIONAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue