C500   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 120
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 7 2
1
<?php
2
3
namespace NFePHP\EFD\Elements\Contribuicoes;
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 = 3;
13
    const PARENT = 'C001';
14
15
    protected $parameters = [
16
        'COD_PART' => [
17
            'type' => 'string',
18
            'regex' => '^.{0,60}$',
19
            'required' => false,
20
            'info' => 'Código do participante do fornecedor (campo 02 do Registro 0150).',
21
            'format' => ''
22
        ],
23
        'COD_MOD' => [
24
            'type' => 'string',
25
            'regex' => '^(00|01|02|03|06|07|08)$',
26
            'required' => false,
27
            'info' => 'Código do modelo do documento fiscal, conforme a Tabela 4.1.1',
28
            'format' => ''
29
        ],
30
        'COD_SIT' => [
31
            'type' => 'numeric',
32
            'regex' => '^(\d{2})$',
33
            'required' => false,
34
            'info' => 'Código da situação do documento fiscal, conforme a Tabela 4.1.2',
35
            'format' => ''
36
        ],
37
        'SER' => [
38
            'type' => 'string',
39
            'regex' => '^.{0,4}$',
40
            'required' => false,
41
            'info' => 'Série do documento fiscal',
42
            'format' => ''
43
        ],
44
        'SUB' => [
45
            'type' => 'numeric',
46
            'regex' => '^(\d{0,3})$',
47
            'required' => false,
48
            'info' => 'Subsérie do documento fiscal',
49
            'format' => ''
50
        ],
51
        'NUM_DOC' => [
52
            'type' => 'numeric',
53
            'regex' => '^(\d{0,9})$',
54
            'required' => false,
55
            'info' => 'Número do documento fiscal',
56
            'format' => ''
57
        ],
58
        'DT_DOC' => [
59
            'type' => 'string',
60
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
61
            'required' => false,
62
            'info' => 'Data da emissão do documento fiscal',
63
            'format' => ''
64
        ],
65
        'DT_ENT' => [
66
            'type' => 'string',
67
            'regex' => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
68
            'required' => false,
69
            'info' => 'Data da entrada',
70
            'format' => ''
71
        ],
72
        'VL_DOC' => [
73
            'type' => 'numeric',
74
            'regex' => '^\d+(\.\d*)?|\.\d+$',
75
            'required' => false,
76
            'info' => 'Valor total do documento fiscal',
77
            'format' => '15v2'
78
        ],
79
        'VL_ICMS' => [
80
            'type' => 'numeric',
81
            'regex' => '^\d+(\.\d*)?|\.\d+$',
82
            'required' => false,
83
            'info' => 'Valor acumulado do ICMS',
84
            'format' => '15v2'
85
        ],
86
        'COD_INF' => [
87
            'type' => 'string',
88
            'regex' => '^.{0,6}$',
89
            'required' => false,
90
            'info' => 'Código da informação complementar do documento fiscal (campo 02 do Registro 0450)',
91
            'format' => ''
92
        ],
93
        'VL_PIS' => [
94
            'type' => 'numeric',
95
            'regex' => '^\d+(\.\d*)?|\.\d+$',
96
            'required' => false,
97
            'info' => 'Valor do PIS/PASEP',
98
            'format' => '15v2'
99
        ],
100
        'VL_COFINS' => [
101
            'type' => 'numeric',
102
            'regex' => '^\d+(\.\d*)?|\.\d+$',
103
            'required' => false,
104
            'info' => 'Valor da COFINS',
105
            'format' => '15v2'
106
        ],
107
108
    ];
109
110
    /**
111
     * Constructor
112
     * @param \stdClass $std
113
     */
114
    public function __construct(\stdClass $std)
115
    {
116
        parent::__construct(self::REG);
117
        $this->std = $this->standarize($std);
118
        $this->postValidation();
119
    }
120
121
    public function postValidation()
122
    {
123
        if ($this->values->vl_doc <= 0) {
124
            throw new \InvalidArgumentException("[" . self::REG . "] " .
125
                "O campo VL_DOC deve ser maior que “0” ");
126
        }
127
    }
128
}
129