PHP Myanmar Phone Number

v1.1.0 2023-02-26 14:22 UTC

README

Run tests Packagist Downloads

Phone Number

PHP Myanmar Phone Number for Laravel Myanmar Tools

Credit: Original script (PHP) Original script (JS)

Installation

composer require laravel-myanmar-tools/phone-number

Usage

Check Myanmar Phone Number

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMyanmarPhoneNumber('09250000000'); // return true

Check MPT

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMpt('09250000000'); // return true

Check Ooredoo

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isOoredoo('09970000000'); // return true

Check Telenor

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isTelenor('09790000000'); // return true

Check MEC

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMec('0930000000'); // return true

Check Mytel

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->isMytel('09690000000'); // return true

Get Telecom

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->getTelecom('09250000000'); // return "mpt"
$phoneNumber->getTelecom('09970000000'); // return "ooredoo"
$phoneNumber->getTelecom('09790000000'); // return "telenor"
$phoneNumber->getTelecom('0930000000'); // return "mec"
$phoneNumber->getTelecom('09690000000'); // return "mytel"

Get Network Type

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->getNetworkType('09250000000'); // return "gsm"
$phoneNumber->getNetworkType('09440000000'); // return "wcdma"

Normalize

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->normalize('09250000000'); // return "09250000000"
$phoneNumber->normalize('(၀၉)၂၅၀၀၀၀၀၀၀'); // return "09250000000"
$phoneNumber->normalize('၀၉-၂၅၀၀၀၀၀၀၀'); // return "09250000000"
$phoneNumber->normalize('09-၂၅ဝရဝရဝရဝ'); // return "09250000000"

$phoneNumber->normalize('09250000000', '+959'); // return "+959250000000"

Extract Myanmar Phone Number

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMyanmarPhoneNumber('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်များမှာ ၀၉၂၅၀၀၀၀၀၀၀ နှင့် ၀၉၉၇၀၀၀၀၀၀၀ တို့ဖြစ်ပါသည်။'); 
// return ["09250000000", "09970000000"]

Extract Mpt

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMpt('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09250000000 ဖြစ်ပါသည်။'); 
// return ["09250000000"]

Extract Ooredoo

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractOoredoo('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09970000000 ဖြစ်ပါသည်။'); 
// return ["09970000000"]

Extract Telenor

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractTelenor('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09790000000 ဖြစ်ပါသည်။'); 
// return ["09790000000"]

Extract Mec

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMec('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 0930000000 ဖြစ်ပါသည်။'); 
// return ["0930000000"]

Extract Mytel

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;
$phoneNumber->extractMytel('မောင်မောင်ရဲ့ ဖုန်းနံပါတ်မှာ 09690000000 ဖြစ်ပါသည်။'); 
// return ["09690000000"]

Customize

use LaravelMyanmarTools\PhoneNumber\PhoneNumber;

$phoneNumber = new PhoneNumber;

$phoneNumber::macro('isAtom', function(string $phone) {
   return $this->isTelenor(phone: $phone);
});

$phoneNumber->isAtom('09790000000'); // return true

Testing

composer test