1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NFePHP\ECD\Elements; |
4
|
|
|
|
5
|
|
|
use NFePHP\ECD\Common\Element; |
6
|
|
|
use NFePHP\ECD\Common\ElementInterface; |
7
|
|
|
use \stdClass; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Elemento J900 do Bloco J OBRIGATÓRIO [1:1] |
11
|
|
|
* REGISTRO J900: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA |
12
|
|
|
*/ |
13
|
|
View Code Duplication |
class J900 extends Element implements ElementInterface |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
const REG = 'J900'; |
16
|
|
|
const LEVEL = 2; |
17
|
|
|
const PARENT = ''; |
18
|
|
|
|
19
|
|
|
protected $parameters = [ |
20
|
|
|
'dnrc_encer' => [ |
21
|
|
|
'type' => 'string', |
22
|
|
|
'regex' => '^(TERMO DE ENCERRAMENTO)$', |
23
|
|
|
'required' => true, |
24
|
|
|
'info' => 'Texto fixo contendo TERMO DE ENCERRAMENTO.', |
25
|
|
|
'format' => '' |
26
|
|
|
], |
27
|
|
|
'num_ord' => [ |
28
|
|
|
'type' => 'numeric', |
29
|
|
|
'regex' => '^[0-9]$', |
30
|
|
|
'required' => true, |
31
|
|
|
'info' => 'Número de ordem do instrumento de escrituração.', |
32
|
|
|
'format' => '' |
33
|
|
|
], |
34
|
|
|
'nat_livro' => [ |
35
|
|
|
'type' => 'string', |
36
|
|
|
'regex' => '^[A-Za-z0-9]{80}$', |
37
|
|
|
'required' => true, |
38
|
|
|
'info' => 'Natureza do livro; finalidade a que se destinou o instrumento.', |
39
|
|
|
'format' => '' |
40
|
|
|
], |
41
|
|
|
'nome' => [ |
42
|
|
|
'type' => 'string', |
43
|
|
|
'regex' => '^[A-Za-z0-9]$', |
44
|
|
|
'required' => true, |
45
|
|
|
'info' => 'Nome empresarial.', |
46
|
|
|
'format' => '' |
47
|
|
|
], |
48
|
|
|
'num_lin' => [ |
49
|
|
|
'type' => 'numeric', |
50
|
|
|
'regex' => '^[0-9]$', |
51
|
|
|
'required' => true, |
52
|
|
|
'info' => 'Quantidade total de linhas do arquivo digital.', |
53
|
|
|
'format' => '' |
54
|
|
|
], |
55
|
|
|
'dt_ini_escr' => [ |
56
|
|
|
'type' => 'string', |
57
|
|
|
'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', |
58
|
|
|
'required' => true, |
59
|
|
|
'info' => 'Data inicial da escrituração.', |
60
|
|
|
'format' => '' |
61
|
|
|
], |
62
|
|
|
'dt_fin_escr' => [ |
63
|
|
|
'type' => 'string', |
64
|
|
|
'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$', |
65
|
|
|
'required' => true, |
66
|
|
|
'info' => 'Data de término da escrituração.', |
67
|
|
|
'format' => '' |
68
|
|
|
] |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Constructor |
73
|
|
|
* @param \stdClass $std |
74
|
|
|
*/ |
75
|
|
|
public function __construct(\stdClass $std) |
76
|
|
|
{ |
77
|
|
|
parent::__construct(self::REG); |
78
|
|
|
$this->std = $this->standarize($std); |
79
|
|
|
$this->postValidation(); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.