Path: blob/master/src/applications/metamta/message/PhabricatorPhoneNumber.php
12256 views
<?php12final class PhabricatorPhoneNumber3extends Phobject {45private $number;67public function __construct($raw_number) {8$number = preg_replace('/[^\d]+/', '', $raw_number);910if (!preg_match('/^[1-9]\d{9,14}\z/', $number)) {11throw new Exception(12pht(13'Phone number ("%s") is not in a recognized format: expected a '.14'US number like "(555) 555-5555", or an international number '.15'like "+55 5555 555555".',16$raw_number));17}1819// If the number didn't start with "+" and has has 10 digits, assume it is20// a US number with no country code prefix, like "(555) 555-5555".21if (!preg_match('/^[+]/', $raw_number)) {22if (strlen($number) === 10) {23$number = '1'.$number;24}25}2627$this->number = $number;28}2930public function toE164() {31return '+'.$this->number;32}3334}353637