Completed
Push — master ( df7a74...493c6b )
by Roberto
15:39 queued 23s
created

I030::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 I030 do Bloco I OBRIGATÓRIO [1:1]
11
 * REGISTRO I030: TERMO DE ABERTURA
12
 */
13
class I030 extends Element implements ElementInterface
14
{
15
    const REG = 'I030';
16
    const LEVEL = 3;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'dnrc_abert' => [
21
            'type'     => 'string',
22
            'regex'    => '^(TERMO DE ABERTURA){17}$',
23
            'required' => true,
24
            'info'     => 'Termo de Abertura.',
25
            'format'   => ''
26
        ],
27
        'num_ord'    => [
28
            'type'     => 'numeric',
29
            'regex'    => '^([1-9][0-9]*)$',
30
            'required' => true,
31
            'info'     => 'Número de ordem do instrumento associado.',
32
            'format'   => ''
33
        ],
34
        'nat_liv' => [
35
            'type'     => 'string',
36
            'regex'    => '^[A-Za-z0-9]{80}$',
37
            'required' => true,
38
            'info'     => 'Natureza do livro associado; finalidade a que se destina o instrumento.',
39
            'format'   => ''
40
        ],
41
        'qtd_lin' => [
42
            'type'     => 'numeric',
43
            'regex'    => '^([0-9]*)$',
44
            'required' => true,
45
            'info'     => '0 - Bloco com dados informados;1- Bloco sem dados informados.',
46
            'format'   => ''
47
        ],
48
        'nome' => [
49
            'type'     => 'string',
50
            'regex'    => '^[A-Za-z0-9]$',
51
            'required' => true,
52
            'info'     => 'Nome Empresarial.',
53
            'format'   => ''
54
        ],
55
        'nire' => [
56
            'type'     => 'numeric',
57
            'regex'    => '^([0-9]){11}$',
58
            'required' => false,
59
            'info'     => 'Número de Identificação do Registro de Empresas da Junta Comercial',
60
            'format'   => ''
61
        ],
62
        'cnpj' => [
63
            'type'     => 'string',
64
            'regex'    => '^[0-9]{14}$',
65
            'required' => true,
66
            'info'     => 'Número de inscrição da entidade no CNPJ.',
67
            'format'   => ''
68
        ],
69
        'dt_arq'     => [
70
            'type'     => 'string',
71
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
72
            'required' => false,
73
            'info'     => 'Data do arquivamento dos atos constitutivos.',
74
            'format'   => ''
75
        ],
76
        'dt_arq_conv'     => [
77
            'type'     => 'string',
78
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
79
            'required' => false,
80
            'info'     => 'Data de arquivamento do ato de conversão de sociedade simples em sociedade empresária.',
81
            'format'   => ''
82
        ],
83
        'desc_mun' => [
84
            'type'     => 'string',
85
            'regex'    => '^[A-Za-z0-9]$',
86
            'required' => false,
87
            'info'     => 'Municipio.',
88
            'format'   => ''
89
        ],
90
        'dt_ex_social'     => [
91
            'type'     => 'string',
92
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
93
            'required' => false,
94
            'info'     => 'Data de encerramento do exercicio social.',
95
            'format'   => ''
96
        ]
97
    ];
98
99
    /**
100
     * Constructor
101
     * @param \stdClass $std
102
     */
103
    public function __construct(\stdClass $std)
104
    {
105
        parent::__construct(self::REG);
106
        $this->std = $this->standarize($std);
107
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\I030::postValidation() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
108
    }
109
}
110