Completed
Push — master ( 74d6ff...309b24 )
by Roberto
43:07 queued 28:08
created

C500::strToFloat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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 C500 extends Element implements ElementInterface
10
{
11
    const REG = 'C500';
12
    const LEVEL = 2;
13
    const PARENT = 'C001';
14
15
    protected $parameters = [
16
        'IND_OPER' => [
17
            'type' => 'string',
18
            'regex' => '^.{1}$',
19
            'required' => true,
20
            'info' => 'Indicador do tipo de operação',
21
            'format' => ''
22
        ],
23
        'IND_EMIT' => [
24
            'type' => 'string',
25
            'regex' => '^.{1}$',
26
            'required' => true,
27
            'info' => 'Indicador do emitente do documento fiscal',
28
            'format' => ''
29
        ],
30
        'COD_PART' => [
31
            'type' => 'string',
32
            'regex' => '^.{1,60}$',
33
            'required' => true,
34
            'info' => 'Código do participante (campo 02 do Registro 0150)',
35
            'format' => ''
36
        ],
37
        'COD_MOD' => [
38
            'type' => 'string',
39
            'regex' => '^.{2}$',
40
            'required' => true,
41
            'info' => 'Código do modelo conforme a Tabela 4.1.1',
42
            'format' => ''
43
        ],
44
        'COD_SIT' => [
45
            'type' => 'numeric',
46
            'regex' => '^(\d{2})$',
47
            'required' => true,
48
            'info' => 'Código da situação conforme a Tabela 4.1.2',
49
            'format' => ''
50
        ],
51
        'SER' => [
52
            'type' => 'string',
53
            'regex' => '^.{0,4}$',
54
            'required' => false,
55
            'info' => 'Série do documento fiscal',
56
            'format' => ''
57
        ],
58
        'SUB' => [
59
            'type' => 'numeric',
60
            'regex' => '^(\d{0,3})$',
61
            'required' => false,
62
            'info' => 'Subsérie do documento fiscal',
63
            'format' => ''
64
        ],
65
        'COD_CONS' => [
66
            'type' => 'string',
67
            'regex' => '^.{2}$',
68
            'required' => false,
69
            'info' => 'Código de classe de consumo de energia elétrica ou gás',
70
            'format' => ''
71
        ],
72
        'NUM_DOC' => [
73
            'type' => 'numeric',
74
            'regex' => '^(\d{1,9})$',
75
            'required' => true,
76
            'info' => 'Número do documento fiscal',
77
            'format' => ''
78
        ],
79
        'DT_DOC' => [
80
            'type' => 'string',
81
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
82
            'required' => true,
83
            'info' => 'Data da emissão do documento fiscal',
84
            'format' => ''
85
        ],
86
        'DT_E_S' => [
87
            'type' => 'string',
88
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
89
            'required' => true,
90
            'info' => 'Data da entrada ou da saída',
91
            'format' => ''
92
        ],
93
        'VL_DOC' => [
94
            'type' => 'numeric',
95
            'regex' => '^\d+(\.\d*)?|\.\d+$',
96
            'required' => true,
97
            'info' => 'Valor total do documento fiscal',
98
            'format' => '15v2'
99
        ],
100
        'VL_DESC' => [
101
            'type' => 'numeric',
102
            'regex' => '^\d+(\.\d*)?|\.\d+$',
103
            'required' => false,
104
            'info' => 'Valor total do desconto',
105
            'format' => '15v2'
106
        ],
107
        'VL_FORN' => [
108
            'type' => 'numeric',
109
            'regex' => '^\d+(\.\d*)?|\.\d+$',
110
            'required' => true,
111
            'info' => 'Valor total fornecido/consumido',
112
            'format' => '15v2'
113
        ],
114
        'VL_SERV_NT' => [
115
            'type' => 'numeric',
116
            'regex' => '^\d+(\.\d*)?|\.\d+$',
117
            'required' => false,
118
            'info' => 'Valor total dos serviços não-tributados pelo ICMS',
119
            'format' => '15v2'
120
        ],
121
        'VL_TERC' => [
122
            'type' => 'numeric',
123
            'regex' => '^\d+(\.\d*)?|\.\d+$',
124
            'required' => false,
125
            'info' => 'Valor total cobrado em nome de terceiros',
126
            'format' => '15v2'
127
        ],
128
        'VL_DA' => [
129
            'type' => 'numeric',
130
            'regex' => '^\d+(\.\d*)?|\.\d+$',
131
            'required' => false,
132
            'info' => 'Valor total de despesas acessórias indicadas no',
133
            'format' => '15v2'
134
        ],
135
        'VL_BC_ICMS' => [
136
            'type' => 'numeric',
137
            'regex' => '^\d+(\.\d*)?|\.\d+$',
138
            'required' => false,
139
            'info' => 'Valor acumulado da base de cálculo do ICMS',
140
            'format' => '15v2'
141
        ],
142
        'VL_ICMS' => [
143
            'type' => 'numeric',
144
            'regex' => '^\d+(\.\d*)?|\.\d+$',
145
            'required' => false,
146
            'info' => 'Valor acumulado do ICMS',
147
            'format' => '15v2'
148
        ],
149
        'VL_BC_ICMS_ST' => [
150
            'type' => 'numeric',
151
            'regex' => '^\d+(\.\d*)?|\.\d+$',
152
            'required' => false,
153
            'info' => 'Valor acumulado da base de cálculo do ICMS substituição tributária',
154
            'format' => '15v2'
155
        ],
156
        'VL_ICMS_ST' => [
157
            'type' => 'numeric',
158
            'regex' => '^\d+(\.\d*)?|\.\d+$',
159
            'required' => false,
160
            'info' => 'Valor acumulado substituição tributária',
161
            'format' => '15v2'
162
        ],
163
        'COD_INF' => [
164
            'type' => 'string',
165
            'regex' => '^.{0,6}$',
166
            'required' => false,
167
            'info' => 'Código da informação complementar do documento fiscal (campo 02 do Registro 0450)',
168
            'format' => ''
169
        ],
170
        'VL_PIS' => [
171
            'type' => 'numeric',
172
            'regex' => '^\d+(\.\d*)?|\.\d+$',
173
            'required' => false,
174
            'info' => 'Valor do PIS',
175
            'format' => '15v2'
176
        ],
177
        'VL_COFINS' => [
178
            'type' => 'numeric',
179
            'regex' => '^\d+(\.\d*)?|\.\d+$',
180
            'required' => false,
181
            'info' => 'Valor da COFINS',
182
            'format' => '15v2'
183
        ],
184
        'TP_LIGACAO' => [
185
            'type' => 'numeric',
186
            'regex' => '^([1-3]{1})$',
187
            'required' => false,
188
            'info' => 'Código de tipo de Ligação',
189
            'format' => ''
190
        ],
191
        'COD_GRUPO_TENSAO' => [
192
            'type' => 'string',
193
            'regex' => '^([0-1]{1})([0-9]{1})$',
194
            'required' => false,
195
            'info' => 'Código de grupo de tensão',
196
            'format' => ''
197
        ],
198
199
    ];
200
201
    /**
202
     * Constructor
203
     * @param \stdClass $std
204
     */
205
    public function __construct(\stdClass $std)
206
    {
207
        parent::__construct(self::REG);
208
        $this->std = $this->standarize($std);
209
    }
210
211 View Code Duplication
    public function postValidation()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
212
    {
213
        if ($this->values->vl_doc <= 0) {
214
            throw new \InvalidArgumentException("[" . self::REG . "] " .
215
                " O do campo VL_DOC deve ser maior do que 0");
216
        }
217
        if ($this->values->vl_forn <= 0) {
218
            throw new \InvalidArgumentException("[" . self::REG . "] " .
219
                " O do campo VL_FORN deve ser maior do que 0");
220
        }
221
    }
222
}
223