PHP code example of amine-zhioua / degache-php

1. Go to this page and download the library: Download amine-zhioua/degache-php 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/ */

    

amine-zhioua / degache-php example snippets


use AmineZhioua\DegachePhp\Degache;

Degache::validatePhoneNumber('20123456'); // true

use AmineZhioua\DegachePhp\Validators\PhoneValidator;

PhoneValidator::validate('20123456'); // true

use AmineZhioua\DegachePhp\Degache;

Degache::validatePhoneNumber('20123456');           // true
Degache::validatePhoneNumber('+21620123456');       // true
Degache::validatePhoneNumber('10123456');           // false — invalid prefix

// Strict mode rejects spaces, hyphens, parentheses
Degache::validatePhoneNumber('20 123 456', strict: true); // false

$carrier = Degache::getPhoneCarrierInfo('90123456');
// $carrier->name === 'Tunisie Telecom'
// $carrier->prefixes === ['2', '9']

Degache::formatPhoneNumber('+21620123456');
// "+216 20 123 456"

use AmineZhioua\DegachePhp\Degache;

Degache::validateCIN('12345678'); // true
Degache::validateCIN('99999999'); // false — must start with 0 or 1

use AmineZhioua\DegachePhp\Degache;

Degache::validateRIB('01123456789012345678'); // true — ATB
Degache::validateRIB('99123456789012345678'); // false — unknown bank code

$bank = Degache::getBankInfoFromRIB('08123456789012345678');
// $bank->code === '08'
// $bank->name === 'Banque Internationale Arabe de Tunisie'

use AmineZhioua\DegachePhp\Degache;
use AmineZhioua\DegachePhp\Enums\CarPlateType;

Degache::validateCarPlate('123 تونس 4567');            // true
Degache::validateCarPlate('RS 123 تونس');               // true
Degache::validateCarPlate('rs 123 تونس');               // true — normalized

// Restrict to one type
Degache::validateCarPlate('RS 123 تونس', type: CarPlateType::Standard); // false

// Strict mode: no normalization, exact Arabic text 

use AmineZhioua\DegachePhp\Degache;

Degache::validatePostalCode('2001'); // true — Ariana
Degache::validatePostalCode('9999'); // false — well-formed but doesn't exist

use AmineZhioua\DegachePhp\Degache;

Degache::validateTaxID('1234567A/B/C/000'); // true
Degache::validateTaxID('1234567a/B/C/000'); // false — must be uppercase

use AmineZhioua\DegachePhp\Degache;

Degache::formatCurrency(1234.56);
// "1.234,560 دينار تونسي"

Degache::formatCurrency(1234.56, symbol: true);
// "1.234,560 د.ت"

Degache::formatCurrency(1234.56, code: true);
// "1.234,560 TND"

use AmineZhioua\DegachePhp\Degache;
use IntlDateFormatter;

$date = new DateTimeImmutable('2024-01-15');

Degache::formatDate($date);
// "15 جانفي 2024"

Degache::formatDate($date, IntlDateFormatter::FULL);
// "الاثنين، 15 جانفي 2024"
bash
composer