Skip to content

Commit 5219c56

Browse files
committed
Feat: Create methods to default formats.
1 parent 634da57 commit 5219c56

File tree

3 files changed

+324
-46
lines changed

3 files changed

+324
-46
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ $mask->cep('89566410');
3030
# returns '198.298.398-98'
3131
$mask->cpf('19829839898');
3232

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

3636
# returns '12.345.678-9'
3737
$mask->rg('123456789');

src/Constants.php

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,66 @@
44

55
class Constants
66
{
7+
/* Supported types */
8+
const CEP = "CEP";
9+
const CPF = "CPF";
10+
const CNPJ = "CNPJ";
11+
const DATE = "DATE";
12+
const RG = "RG";
13+
const PHONE = "PHONE";
14+
const CELL_PHONE = "CELL_PHONE";
15+
const CUSTOM = "CUSTOM";
16+
const CREDIT_CARD = "CREDIT_CARD";
17+
718
/**
8-
* 🇧🇷 Tamanho exato de cada tipo de informação
9-
* 🇺🇸 Exact size of each type of information
10-
* 🇮🇹 Dimensione esatta di ogni tipo di informazione
19+
* Masks of any supported type
20+
*
21+
* @const LENGHT
22+
*/
23+
const MASK = [
24+
"CEP" => "#####-###",
25+
"CPF" => "###.###.###-##",
26+
"CNPJ" => "##.###.###/####-##",
27+
"DATE" => "##/##/####",
28+
"RG" => "##.###.###-#",
29+
"PHONE" => "(##) ####-####",
30+
"CELL_PHONE" => "(##) #####-####",
31+
"CREDIT_CARD" => "####.****.****.####"
32+
];
33+
34+
/**
35+
* Define auto complete type (with zero to the left)
36+
*
37+
* @const LENGHT
38+
*/
39+
const AUTO_COMPLETE = [
40+
"CEP",
41+
"CPF",
42+
"CNPJ",
43+
"RG"
44+
];
45+
46+
/**
47+
* Exact size of each type of information
48+
*
49+
* @const LENGHT
1150
*/
1251
const LENGTH = [
1352
'CEP' => 8,
14-
'CPF' => 11
53+
'CPF' => 11,
54+
'CNPJ' => 14,
55+
'RG' => 9,
56+
'PHONE' => 10
57+
];
58+
59+
/**
60+
* Define mask class errors
61+
*
62+
* @const ERROR
63+
*/
64+
const ERROR = [
65+
'NULL' => 'The value entered is null.',
66+
'INVALID' => 'Not supported type entered.'
1567
];
68+
1669
}

0 commit comments

Comments
 (0)