| | 218 | * Checks if a phone number is valid. |
| | 219 | * |
| | 220 | * @todo This function is not l10n-compatible. |
| | 221 | * |
| | 222 | * @param string phone number to check |
| | 223 | * @return boolean |
| | 224 | */ |
| | 225 | public static function phone($number) |
| | 226 | { |
| | 227 | $number = preg_replace('/[^0-9]/', '', $number); |
| | 228 | |
| | 229 | if (strlen($number) > 10 AND substr($number, 0, 1) === '1') |
| | 230 | { |
| | 231 | // Remove the "1" prefix from the number |
| | 232 | $number = substr($number, 1); |
| | 233 | } |
| | 234 | |
| | 235 | // If the length is not 10, it's not a valid number |
| | 236 | return (strlen($number) === 10); |
| | 237 | } |
| | 238 | |
| | 239 | /** |