Class in PHP to work with CPF
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Cpf.php
README.md

README.md

The Cpf class

A CPF number is called a Cadastro de Pessoa Física or translated “Registration of a Physical Person” and with this class you can apply the validation of this number in your application and display its formatted value.

Usage

CPF number valid, the following code uses a hypothetical number

$cpf = new Cpf('06115058511');
$cpf->valid(); // true
$cpf->format(); // 061.150.585-11

You can set CPF number ignoring the digits from zero to left

$cpf->set(6115058511); 

You can set CPF number formatted

$cpf->set('061.150.585-11'); 

CPF number invalid

$cpf = new Cpf('21601543695'); 
$cpf->valid(); // false
$cpf->format(); // NULL