@@ -17,7 +17,7 @@ Install the library using [composer][1]. Add the following to your `composer.jso
17
17
``` json
18
18
{
19
19
"require" : {
20
- "brazanation/documents" : " 0.7 .*"
20
+ "brazanation/documents" : " 0.8 .*"
21
21
}
22
22
}
23
23
```
@@ -31,22 +31,34 @@ $ composer.phar install
31
31
or
32
32
33
33
``` sh
34
- $ composer require brazanation/documents 0.7 .*
34
+ $ composer require brazanation/documents 0.8 .*
35
35
```
36
36
37
37
### CPF (cadastro de pessoas físicas)
38
38
39
39
Registration of individuals or Tax Identification
40
40
41
+ ``` php
42
+ use Brazanation\Documents\Cpf;
43
+
44
+ $document = Cpf::createFromString('06843273173');
45
+ if (false === $cpf) {
46
+ echo "Not Valid";
47
+ }
48
+ echo $document; // prints 06843273173
49
+ echo $document->format(); // prints 068.432.731-73
50
+
51
+ ```
52
+ or
41
53
``` php
42
54
use Brazanation\Documents\Cpf;
43
55
use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
44
56
45
57
try {
46
- $cpf = new Cpf('06843273173');
47
- echo $cpf ; // prints 06843273173
48
- echo $cpf ->format(); // prints 068.432.731-73
49
- }catch (InvalidDocumentException $e){
58
+ $document = new Cpf('06843273173');
59
+ echo $document ; // prints 06843273173
60
+ echo $document ->format(); // prints 068.432.731-73
61
+ } catch (InvalidDocumentException $e) {
50
62
echo $e->getMessage();
51
63
}
52
64
```
@@ -57,15 +69,14 @@ Company Identification or National Register of Legal Entities
57
69
58
70
``` php
59
71
use Brazanation\Documents\Cnpj;
60
- use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
61
72
62
- try {
63
- $cnpj = new Cnpj('99999090910270');
64
- echo $cnpj; // prints 99999090910270
65
- echo $cnpj->format(); // prints 99.999.090/9102-70
66
- }catch (InvalidDocumentException $e){
67
- echo $e->getMessage();
73
+ $document = Cnpj::createFromString('99999090910270');
74
+
75
+ if (false === $document) {
76
+ echo "Not Valid";
68
77
}
78
+ echo $document; // prints 99999090910270
79
+ echo $document->format(); // prints 99.999.090/9102-70
69
80
```
70
81
71
82
### CNH (carteira nacional de habilitação)
@@ -74,15 +85,14 @@ National Driving License
74
85
75
86
``` php
76
87
use Brazanation\Documents\Cnh;
77
- use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
78
88
79
- try {
80
- $cnh = new Cnh('83592802666');
81
- echo $cnh; // prints 83592802666
82
- echo $cnh->format(); // prints 83592802666
83
- }catch (InvalidDocumentException $e){
84
- echo $e->getMessage();
89
+ $document = Cnh::createFromString('83592802666');
90
+
91
+ if (false === $document) {
92
+ echo "Not Valid";
85
93
}
94
+ echo $cnh; // prints 83592802666
95
+ echo $cnh->format(); // prints 83592802666
86
96
```
87
97
88
98
### Chave de Acesso Sped (chave da NFe, CTe e MDFe)
@@ -98,15 +108,14 @@ Available models:
98
108
99
109
``` php
100
110
use Brazanation\Documents\Sped\NFe;
101
- use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
102
111
103
- try {
104
- $accessKey = new NFe('52060433009911002506550120000007801267301613');
105
- echo $accessKey; // prints 52060433009911002506550120000007801267301613
106
- echo $accessKey->format(); // prints 5206 0433 0099 1100 2506 5501 2000 0007 8012 6730 1613
107
- }catch (InvalidDocumentException $e){
108
- echo $e->getMessage();
112
+ $document = NFe::createFromString('52060433009911002506550120000007801267301613');
113
+
114
+ if (false === $document) {
115
+ echo "Not Valid";
109
116
}
117
+ echo $document; // prints 52060433009911002506550120000007801267301613
118
+ echo $document->format(); // prints 5206 0433 0099 1100 2506 5501 2000 0007 8012 6730 1613
110
119
```
111
120
or generate your number
112
121
@@ -133,15 +142,15 @@ Social Integration Program and Training Program of the Heritage of Public Servan
133
142
134
143
``` php
135
144
use Brazanation\Documents\PisPasep;
136
- use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
137
145
138
- try {
139
- $pispasep = new PisPasep('51.82312.94-92');
140
- echo $pispasep; // prints 51823129492
141
- echo $pispasep->format(); // prints 51.82312.94-92
142
- }catch (InvalidDocumentException $e){
143
- echo $e->getMessage();
146
+ $document = PisPasep::createFromString('51.82312.94-92');
147
+
148
+ if (false === $document) {
149
+ echo "Not Valid";
144
150
}
151
+
152
+ echo $document; // prints 51823129492
153
+ echo $document->format(); // prints 51.82312.94-92
145
154
```
146
155
147
156
### Título de Eleitor
@@ -150,16 +159,16 @@ Voter Registration
150
159
151
160
``` php
152
161
use Brazanation\Documents\Voter;
153
- use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
154
162
155
- try {
156
- $voter = new Voter('106644440302', 20, 42);
157
- echo $voter; // prints 106644440302
158
- echo $voter->getSection(); // prints 0020
159
- echo $voter->getZone(); // prints 042
160
- }catch (InvalidDocumentException $e){
161
- echo $e->getMessage();
163
+ $document = Voter::createFromString('106644440302', 20, 42);
164
+
165
+ if (false === $document) {
166
+ echo "Not Valid";
162
167
}
168
+
169
+ echo $document; // prints 106644440302
170
+ echo $document->getSection(); // prints 0020
171
+ echo $document->getZone(); // prints 042
163
172
```
164
173
165
174
### Inscrição Estadual
@@ -168,11 +177,6 @@ State Registration
168
177
169
178
``` php
170
179
use Brazanation\Documents\StateRegistration;
171
- use Brazanation\Documents\Exception\InvalidDocument as InvalidDocumentException;
172
-
173
- $state = StateRegistration::AC('0100482300112');
174
- echo $state; // prints 0100482300112
175
- echo $state->format(); // prints 01.004.823/001-12
176
180
177
181
// for Commercial São Paulo
178
182
$state = StateRegistration::SP('110.042.490.114');
@@ -183,6 +187,17 @@ echo $state->format(); // prints 110.042.490.114
183
187
$state = StateRegistration::SP('P011004243002');
184
188
echo $state; // prints P011004243002
185
189
echo $state->format(); // prints P-01100424.3/002
190
+ ```
191
+ or
192
+ ``` php
193
+ use Brazanation\Documents\StateRegistration;
194
+
195
+ $document = StateRegistration::createFromString('P011004243002', 'SP');
196
+
197
+ if (false === $document) {
198
+ echo "Not Valid";
199
+ }
200
+
186
201
```
187
202
188
203
### Cartão Nacional de Saúde (SUS)
@@ -192,9 +207,14 @@ National Health Card
192
207
``` php
193
208
use Brazanation\Documents\Cns;
194
209
195
- $cns = new Cns('242912018460005')
196
- echo $cns; // prints 242912018460005
197
- echo $cns->format(); // prints 242 9120 1846 0005
210
+ $document = Cns::createFromString('242912018460005');
211
+
212
+ if (false === $document) {
213
+ echo "Not Valid";
214
+ }
215
+
216
+ echo $document; // prints 242912018460005
217
+ echo $document->format(); // prints 242 9120 1846 0005
198
218
```
199
219
200
220
### Renavam (Registro Nacional de Veículos Automotores)
@@ -204,9 +224,14 @@ National Registry of Motor Vehicles
204
224
``` php
205
225
use Brazanation\Documents\Renavam;
206
226
207
- $renavam = new Renavam('61855253306')
208
- echo $renavam; // prints 61855253306
209
- echo $renavam->format(); // prints 6185.525330-6
227
+ $document = Renavam::createFromString('61855253306');
228
+
229
+ if (false === $document) {
230
+ echo "Not Valid";
231
+ }
232
+
233
+ echo $document; // prints 61855253306
234
+ echo $document->format(); // prints 6185.525330-6
210
235
```
211
236
212
237
### Processos Judiciais
@@ -216,9 +241,14 @@ Numbers of legal proceedings related to Judiciary assessments
216
241
``` php
217
242
use Brazanation\Documents\JudiciaryProcess;
218
243
219
- $procjud = new JudiciaryProcess('0048032982009809');
220
- echo $procjud; //prints 0048032982009809
221
- echo $procjud->format(); //prints 0048032.98.2009.8.09.0000
244
+ $document = JudiciaryProcess::createFromString('0048032982009809');
245
+
246
+ if (false === $document) {
247
+ echo "Not Valid";
248
+ }
249
+
250
+ echo $document; //prints 0048032982009809
251
+ echo $document->format(); //prints 0048032.98.2009.8.09.0000
222
252
223
253
```
224
254
0 commit comments