Skip to content

laravel-myanmar-tools/nrc

Repository files navigation

Run tests Packagist Downloads

Nrc

PHP Myanmar Nrc for Laravel Myanmar Tools

Installation

composer require laravel-myanmar-tools/nrc

Usage

Check Nrc

use LaravelMyanmarTools\Nrc\Nrc;

$nrc = new Nrc;

$nrc->isNrc('12/OUKAMA(N)123456'); // return true

$nrc->isNrc('12/OuKaMa(Naing)123456'); // return true

$nrc->isNrc('၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆'); // return true

Normalize Nrc

use LaravelMyanmarTools\Nrc\Nrc;

$nrc = new Nrc;

$nrc->normalizeNrc('12/OUKAMA(N)123456'); // return "12/OUKAMA(N)123456"
$nrc->normalizeNrc('12/OUKAMA(N)123456', 'mm'); // return "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"

$nrc->normalizeNrc('12/OuKaMa(Naing)123456'); // return "12/OUKAMA(N)123456"
$nrc->normalizeNrc('12/OuKaMa(Naing)123456', 'mm'); // return "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"

$nrc->normalizeNrc('၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆'); // return "12/OUKAMA(N)123456"
$nrc->normalizeNrc('၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆', 'mm'); // return "၁၂/ဥကမ(နိုင်)၁၂၃၄၅၆"

Customize

use LaravelMyanmarTools\Nrc\Nrc;
use Illuminate\Support\Str;

$nrc = new Nrc;

$nrc::macro('isYangon', function(string $nrc) {
   return Str::before($nrc, '/') == '12';
});

$nrc->isYangon('12/OuKaMa(Naing)123456'); // return true

Testing

composer test

Credit