PHP code example of joulgs / php-utils

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

    

joulgs / php-utils example snippets



use JGS\Utils\FiscalDocuments;

$doc_number = new FiscalDocuments('12345678901');

echo $doc_number->getType(); // CPF

if($doc_number->isValid()) {
    echo "Valid Doc Number";
}

if($doc_number->isInvalid()) {
    echo "Invalid Doc Number";
}

echo $doc_number->getMasked(); // 123.456.789-01



use JGS\Utils\Tools;

$phone = Tools::formatPhone('1234567890');
echo $phone; // (12) 3456-7890

$phone = Tools::formatPhone('12345678901');
echo $phone; // (12) 34567-8901

$phone = Tools::formatPhone('551234567890');
echo $phone; // +55 (12) 3456-7890

$phone = Tools::formatPhone('5512345678901');
echo $phone; // +55 (12) 34567-8901

$masked = Tools::mask('12345678901', '###.###.###-##');
echo $masked; // 123.456.789-01

$masked = Tools::mask('1234567890', '##-##-##-##');
echo $masked; // 12-34-56-78