Skip to content

Commit

Permalink
Feat: Create methods to default formats.
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldbach07 committed Oct 30, 2021
1 parent 634da57 commit 5219c56
Show file tree
Hide file tree
Showing 3 changed files with 324 additions and 46 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ $mask->cep('89566410');
# returns '198.298.398-98'
$mask->cpf('19829839898');

# returns '3635359000123'
$mask->cnpj('03.635.359/0001-23');
# returns '03.635.359/0001-23'
$mask->cnpj('3635359000123');

# returns '12.345.678-9'
$mask->rg('123456789');
Expand Down
61 changes: 57 additions & 4 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,66 @@

class Constants
{
/* Supported types */
const CEP = "CEP";
const CPF = "CPF";
const CNPJ = "CNPJ";
const DATE = "DATE";
const RG = "RG";
const PHONE = "PHONE";
const CELL_PHONE = "CELL_PHONE";
const CUSTOM = "CUSTOM";
const CREDIT_CARD = "CREDIT_CARD";

/**
* 🇧🇷 Tamanho exato de cada tipo de informação
* 🇺🇸 Exact size of each type of information
* 🇮🇹 Dimensione esatta di ogni tipo di informazione
* Masks of any supported type
*
* @const LENGHT
*/
const MASK = [
"CEP" => "#####-###",
"CPF" => "###.###.###-##",
"CNPJ" => "##.###.###/####-##",
"DATE" => "##/##/####",
"RG" => "##.###.###-#",
"PHONE" => "(##) ####-####",
"CELL_PHONE" => "(##) #####-####",
"CREDIT_CARD" => "####.****.****.####"
];

/**
* Define auto complete type (with zero to the left)
*
* @const LENGHT
*/
const AUTO_COMPLETE = [
"CEP",
"CPF",
"CNPJ",
"RG"
];

/**
* Exact size of each type of information
*
* @const LENGHT
*/
const LENGTH = [
'CEP' => 8,
'CPF' => 11
'CPF' => 11,
'CNPJ' => 14,
'RG' => 9,
'PHONE' => 10
];

/**
* Define mask class errors
*
* @const ERROR
*/
const ERROR = [
'NULL' => 'The value entered is null.',
'INVALID' => 'Not supported type entered.'
];

}
Loading

0 comments on commit 5219c56

Please sign in to comment.