PHP code example of letkode / latam-documents

1. Go to this page and download the library: Download letkode/latam-documents 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/ */

    

letkode / latam-documents example snippets


$processor = new DocumentProcessor();
$result = $processor->process('12.345.678-9', CountryDocumentEnum::CL, DocumentTypeEnum::RUT);

// $result->valid     → true
// $result->formatted → '12.345.678-9'
// $result->normalized → '123456789'

$result->country    // CountryDocumentEnum
$result->type       // DocumentTypeEnum
$result->raw        // string — valor original
$result->normalized // string — sin separadores
$result->formatted  // string — formato canónico del país
$result->valid      // bool

$doc = (new DocumentFactory())->make(CountryDocumentEnum::BR, DocumentTypeEnum::CPF);
$doc->isValid('123.456.789-09');  // bool
$doc->format('12345678909');      // '123.456.789-09'
$doc->normalize('123.456.789-09'); // '12345678909'