PHP code example of algeriany / libyan-guard

1. Go to this page and download the library: Download algeriany/libyan-guard library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

algeriany / libyan-guard example snippets


use algeriany\LibyanGuard\Facades\LibyanPhone;

// Normalize to local format (09xxxxxxxx)
$local = LibyanPhone::normalizeToLocal('+218912345678'); // Returns: 0912345678

// Normalize to international format (+218xxxxxxxxx)
$international = LibyanPhone::normalizeToInternational('0912345678'); // Returns: +218912345678

// Get the network provider ('Madar', 'Libyana', etc.)
$provider = LibyanPhone::getProvider('0912345678'); // Returns: Madar

// Validate phone number format
$isValid = LibyanPhone::isValid('0912345678'); // Returns: true

use algeriany\LibyanGuard\Facades\LibyanBank;

$info = LibyanBank::parse('LY22GUMH0000001234567890');

if ($info) {
    echo $info['bank_name_ar'];            // مصرف الجمهورية
    echo $info['swift_code'];              // GUMHLYTR
    echo $info['is_mathematically_valid']; // true / false
}

use Illuminate\Http\Request;

public function store(Request $request)
{
    $request->validate([
        'phone' => ['