3 final class PhabricatorPhoneNumber
8 public function __construct($raw_number) {
9 $number = preg_replace('/[^\d]+/', '', $raw_number);
11 if (!preg_match('/^[1-9]\d{9,14}\z/', $number)) {
14 'Phone number ("%s") is not in a recognized format: expected a '.
15 'US number like "(555) 555-5555", or an international number '.
16 'like "+55 5555 555555".',
20 // If the number didn't start with "+" and has has 10 digits, assume it is
21 // a US number with no country code prefix, like "(555) 555-5555".
22 if (!preg_match('/^[+]/', $raw_number)) {
23 if (strlen($number) === 10) {
24 $number = '1'.$number;
28 $this->number
= $number;
31 public function toE164() {
32 return '+'.$this->number
;