Z1100   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 133
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 133
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A postValidation() 0 10 3
1
<?php
2
3
namespace NFePHP\EFD\Elements\ICMSIPI;
4
5
use NFePHP\EFD\Common\Element;
6
use NFePHP\EFD\Common\ElementInterface;
7
use \stdClass;
8
9
class Z1100 extends Element implements ElementInterface
10
{
11
    const REG = '1100';
12
    const LEVEL = 2;
13
    const PARENT = '1001';
14
15
    protected $parameters = [
16
        'IND_DOC' => [
17
            'type'     => 'integer',
18
            'regex'    => '^[0|1|2]$',
19
            'required' => true,
20
            'info'     => 'Informe o tipo de documento: '
21
            .'0 – Declaração de Exportação; '
22
            .'1 – Declaração Simplificada de Exportação; '
23
            .'2 – Declaração Única de Exportação.',
24
            'format'   => ''
25
        ],
26
        'NRO_DE' => [
27
            'type'     => 'string',
28
            'regex'    => '^.{1,14}$',
29
            'required' => true,
30
            'info'     => 'Número da declaração',
31
            'format'   => ''
32
        ],
33
        'DT_DE' => [
34
            'type'     => 'integer',
35
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
36
            'required' => true,
37
            'info'     => 'Data da declaração (DDMMAAAA)',
38
            'format'   => ''
39
        ],
40
        'NAT_EXP' => [
41
            'type'     => 'integer',
42
            'regex'    => '^[0|1]$',
43
            'required' => true,
44
            'info'     => 'Preencher com: 0 - Exportação Direta 1 - Exportação Indireta',
45
            'format'   => ''
46
        ],
47
        'NRO_RE' => [
48
            'type'     => 'integer',
49
            'regex'    => '^\d{1,12}$',
50
            'required' => false,
51
            'info'     => 'No do registro de Exportação',
52
            'format'   => ''
53
        ],
54
        'DT_RE' => [
55
            'type'     => 'integer',
56
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
57
            'required' => false,
58
            'info'     => 'Data do Registro de Exportação (DDMMAAAA)',
59
            'format'   => ''
60
        ],
61
        'CHC_EMB' => [
62
            'type'     => 'string',
63
            'regex'    => '^.{1,18}$',
64
            'required' => false,
65
            'info'     => 'No do conhecimento de embarque',
66
            'format'   => ''
67
        ],
68
        'DT_CHC' => [
69
            'type'     => 'integer',
70
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
71
            'required' => false,
72
            'info'     => 'Data do conhecimento de embarque (DDMMAAAA)',
73
            'format'   => ''
74
        ],
75
        'DT_AVB' => [
76
            'type'     => 'integer',
77
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
78
            'required' => true,
79
            'info'     => 'Data da averbação da Declaração de exportação (ddmmaaaa)',
80
            'format'   => ''
81
        ],
82
        'TP_CHC' => [
83
            'type'     => 'integer',
84
            'regex'    => '^0[1-9]|1[0-9]|9[1-3]|20|99$',
85
            'required' => true,
86
            'info'     => 'Informação do tipo de conhecimento de embarque:'
87
            .'01 – AWB; '
88
            .'02 – MAWB; '
89
            .'03 – HAWB; '
90
            .'04 – COMAT; '
91
            .'06 – R. EXPRESSAS; '
92
            .'07 – ETIQ. REXPRESSAS; '
93
            .'08 – HR. EXPRESSAS; '
94
            .'09 – AV7; '
95
            .'10 – BL; '
96
            .'11 – MBL; '
97
            .'12 – HBL; '
98
            .'13 – CRT; '
99
            .'14 – DSIC; '
100
            .'16 – COMAT BL; '
101
            .'17 – RWB; '
102
            .'18 – HRWB; '
103
            .'19 – TIF/DTA; '
104
            .'20 – CP2;'
105
            .'91 – NÂO IATA; '
106
            .'92 – MNAO IATA; '
107
            .'93 – HNAO IATA; '
108
            .'99 – OUTROS.',
109
            'format'   => ''
110
        ],
111
        'PAIS' => [
112
            'type'     => 'string',
113
            'regex'    => '^\d{1,3}$',
114
            'required' => true,
115
            'info'     => 'Código do país de destino da mercadoria (Preencher conforme tabela do SISCOMEX)',
116
            'format'   => ''
117
        ]
118
    ];
119
120
    /**
121
     * Constructor
122
     * @param \stdClass $std
123
     */
124
    public function __construct(\stdClass $std)
125
    {
126
        parent::__construct(self::REG);
127
        $this->std = $this->standarize($std);
128
        $this->postValidation();
129
    }
130
131
    public function postValidation()
132
    {
133
        /*
134
         * Campo 06 (NRO_RE) Preenchimento: este campo deve ser preenchido se o campo IND_DOC for “0” (zero).
135
         */
136
        if ($this->std->ind_doc == 0 && empty($this->std->nro_re)) {
137
            throw new \InvalidArgumentException("[" . self::REG . "] Este campo deve ser preenchido se o "
138
            ."campo IND_DOC for “0” (zero).");
139
        }
140
    }
141
}
142