Z1210   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
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 59
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 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 Z1210 extends Element implements ElementInterface
10
{
11
    const REG = '1210';
12
    const LEVEL = 3;
13
    const PARENT = '1200';
14
15
    protected $parameters = [
16
        'TIPO_UTIL' => [
17
            'type'     => 'string',
18
            'regex'    => '^.{4}$',
19
            'required' => true,
20
            'info'     => 'Tipo de utilização do crédito, conforme tabela indicada no item 5.5.',
21
            'format'   => ''
22
        ],
23
        'NR_DOC' => [
24
            'type'     => 'string',
25
            'regex'    => '^.*$',
26
            'required' => false,
27
            'info'     => 'Número do documento utilizado na baixa de créditos',
28
            'format'   => ''
29
        ],
30
        'VL_CRED_UTIL' => [
31
            'type'     => 'numeric',
32
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
33
            'required' => true,
34
            'info'     => 'Total de crédito utilizado',
35
            'format'   => '15v2'
36
        ],
37
        'CHV_DOCE' => [
38
            'type'     => 'string',
39
            'regex'    => '^\d{44}$',
40
            'required' => false,
41
            'info'     => 'Chave do Documento Eletrônico',
42
            'format'   => ''
43
        ]
44
    ];
45
46
    /**
47
     * Constructor
48
     * @param \stdClass $std
49
     */
50
    public function __construct(\stdClass $std)
51
    {
52
        parent::__construct(self::REG);
53
        $this->std = $this->standarize($std);
54
        $this->postValidation();
55
    }
56
57
    public function postValidation()
58
    {
59
        /*
60
         * Campo 04 (VL_CRED_UTIL) Validação: o valor informado no campo deve ser maior que “0” (zero).
61
         */
62
        if ($this->values->vl_cred_util <= 0) {
63
            throw new \InvalidArgumentException("[" . self::REG . "] O valor informado no campo "
64
            ."VL_CRED_UTIL deve ser maior que “0” (zero).");
65
        }
66
    }
67
}
68