Phone Formatting
Barta automatically normalizes Bangladeshi phone numbers.
Automatic Formatting
Section titled “Automatic Formatting”All numbers are converted to 8801XXXXXXXXX format:
| Input | Output |
|---|---|
1712345678 | 8801712345678 |
01712345678 | 8801712345678 |
8801712345678 | 8801712345678 |
+8801712345678 | 8801712345678 |
Valid Number Patterns
Section titled “Valid Number Patterns”8801[3-9]XXXXXXXXValid prefixes: 013, 014, 015, 016, 017, 018, 019
Invalid Numbers
Section titled “Invalid Numbers”Invalid numbers throw a BartaException:
use Larament\Barta\Exceptions\BartaException;
try { Barta::to('123456')->message('Hello')->send();} catch (BartaException $e) { // "Invalid Bangladeshi mobile number: 123456"}Using the Utility Directly
Section titled “Using the Utility Directly”use Larament\Barta\Helpers\Util;
$formatted = Util::formatPhoneNumber('01712345678');// Returns: '8801712345678'