Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / metamta / message / PhabricatorPhoneNumber.php
blob9d8193685056b7397455ae967893d98ffccfc357
1 <?php
3 final class PhabricatorPhoneNumber
4 extends Phobject {
6 private $number;
8 public function __construct($raw_number) {
9 $number = preg_replace('/[^\d]+/', '', $raw_number);
11 if (!preg_match('/^[1-9]\d{9,14}\z/', $number)) {
12 throw new Exception(
13 pht(
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".',
17 $raw_number));
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;