mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
fix format number
This commit is contained in:
parent
4fd36ad820
commit
f87aebb20c
3 changed files with 7 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue