Strict Uzbek phone parsing for PHP. UzPhoneNumber wraps brick/phonenumber
internally, adds Uzbekistan prefix data, and exposes a small Brick-style
object API without leaking Brick classes.
use Khakimjanovich\UzPhone\Enum\Format;
use Khakimjanovich\UzPhone\UzPhoneNumber;
$phone_number = UzPhoneNumber::parse('(90) 123-45-67');
echo $phone_number; // +998901234567
echo $phone_number->format(Format::MASKED); // +998 90 *** ** 67Most apps only need one thing from Uzbek phone input: parse it into a canonical
object, identify its prefix type, and then decide what their own domain should
accept. uz-phone keeps that surface small, strict, and framework-agnostic.
- Parses Uzbek phone numbers
- Normalizes to E.164:
+998901234567 - Formats display output:
+998 90 123 45 67 - Masks private output:
+998 90 *** ** 67 - Returns prefix data with PHP backed enums
- Uses
brick/phonenumberfor phone-number parsing and formatting - Keeps Uzbek prefix type and operator data in this package
composer require khakimjanovich/uz-phoneRequires PHP 8.2 or newer.
<?php
use Khakimjanovich\UzPhone\Enum\Format;
use Khakimjanovich\UzPhone\ParseException;
use Khakimjanovich\UzPhone\UzPhoneNumber;
try {
$phone_number = UzPhoneNumber::parse('90 123 45 67');
} catch (ParseException $exception) {
echo $exception->error_type->value;
}
$phone_number->getCountryCode(); // 998
$phone_number->getNationalNumber(); // 901234567
$phone_number->format(Format::E164); // +998901234567
$phone_number->format(Format::INTERNATIONAL); // +998 90 123 45 67
$phone_number->format(Format::NATIONAL); // 90 123 45 67
$phone_number->format(Format::MASKED); // +998 90 *** ** 67<?php
use Khakimjanovich\UzPhone\Enum\Operator;
use Khakimjanovich\UzPhone\Enum\Prefix;
use Khakimjanovich\UzPhone\Enum\PrefixType;
use Khakimjanovich\UzPhone\Enum\Region;
use Khakimjanovich\UzPhone\UzPhoneNumber;
$phone_number = UzPhoneNumber::parse('+998901234567');
$phone_number->getPrefix() === Prefix::P90; // true
$phone_number->getOperator() === Operator::BEELINE_UNITEL; // true
$phone_number->getPrefixType() === PrefixType::MOBILE_GSM; // true
$phone_number->getOperator()?->value; // beeline_unitel
$phone_number->getOperator()?->label(); // Beeline (Unitel)
$phone_number->getAllocationRegion() === Region::TASHKENT; // true
$phone_number->getAllocationRegion()?->label(); // TashkentPrefix data reflects original numbering allocation, not a guaranteed
current operator or location after number portability. Geographic PSTN prefixes
return null from getOperator() because the ITU table names the region, not
a specific operator.
All accepted input normalizes to +998901234567.
+998901234567
998901234567
+998 90 123 45 67
901234567
90 123 45 67
(90) 123-45-67
The parser is intentionally strict. It accepts digits, a leading +, spaces,
parentheses, and hyphens. It rejects unknown prefixes, wrong country codes,
unsupported separators, letters, overlong numbers, and incomplete numbers.
Source: ITU Uzbekistan numbering plan update.
| Prefix | Type | Operator |
|---|---|---|
| 20 | MOBILE_GSM |
OQ_BEELINE |
| 33 | MOBILE_GSM |
HUMANS |
| 36 | FIXED_NETWORK_SERVICE_PROVIDER |
BUZTON |
| 50 | MOBILE_GSM |
UCELL_COSCOM |
| 55 | SIP |
UZTELECOM |
| 61 | GEOGRAPHIC_PSTN |
|
| 62 | GEOGRAPHIC_PSTN |
|
| 65 | GEOGRAPHIC_PSTN |
|
| 66 | GEOGRAPHIC_PSTN |
|
| 67 | GEOGRAPHIC_PSTN |
|
| 69 | GEOGRAPHIC_PSTN |
|
| 70 | GEOGRAPHIC_PSTN |
|
| 71 | GEOGRAPHIC_PSTN |
|
| 72 | GEOGRAPHIC_PSTN |
|
| 73 | GEOGRAPHIC_PSTN |
|
| 74 | GEOGRAPHIC_PSTN |
|
| 75 | GEOGRAPHIC_PSTN |
|
| 76 | GEOGRAPHIC_PSTN |
|
| 77 | MOBILE_GSM |
UZMOBILE_GSM |
| 78 | FIXED_NETWORK_SERVICE_PROVIDER |
|
| 79 | GEOGRAPHIC_PSTN |
|
| 80 | MOBILE_GSM |
PERFECTUM_MOBILE |
| 87 | MOBILE_GSM |
MOBIUZ_UMS |
| 88 | MOBILE_GSM |
MOBIUZ_UMS |
| 90 | MOBILE_GSM |
BEELINE_UNITEL |
| 91 | MOBILE_GSM |
BEELINE_UNITEL |
| 92 | MOBILE_GSM |
BEELINE_UNITEL |
| 93 | MOBILE_GSM |
UCELL_COSCOM |
| 94 | MOBILE_GSM |
UCELL_COSCOM |
| 95 | MOBILE_CDMA_GSM |
UZMOBILE_CDMA |
| 97 | MOBILE_GSM |
MOBIUZ_UMS |
| 98 | MOBILE_CDMA |
PERFECTUM_MOBILE |
| 99 | MOBILE_GSM |
UzPhoneNumber::parse(string $phone_number): UzPhoneNumberparse() throws ParseException when the input is not a valid
Uzbek phone number. The exception exposes ParseErrorType through
$exception->error_type.
UzPhoneNumber methods:
$phone_number->getCountryCode(): string
$phone_number->getNationalNumber(): string
$phone_number->getPrefix(): Prefix
$phone_number->getOperator(): ?Operator
$phone_number->getPrefixType(): PrefixType
$phone_number->getAllocationRegion(): ?Region
$phone_number->format(Format $format): string
$phone_number->isEqualTo(UzPhoneNumber $phone_number): boolParse error types:
ParseErrorType::EMPTY
ParseErrorType::INVALID_CHARACTERS
ParseErrorType::INVALID_COUNTRY_CODE
ParseErrorType::INVALID_LENGTH
ParseErrorType::UNKNOWN_PREFIX
ParseErrorType::UNHANDLED_BRICK_ERRORcomposer testMIT.