Completed
Push — master ( 624185...e43015 )
by Roberto
12:57
created

J150::__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 J150 do Bloco J OBRIGATÓRIO [1:1]
11
 * REGISTRO J150: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 */
13
class J150 extends Element implements ElementInterface
14
{
15
    const REG = 'J150';
16
    const LEVEL = 3;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'nu_ordem'    => [
21
            'type'     => 'numeric',
22
            'regex'    => '^[0-9]{19}$',
23
            'required' => true,
24
            'info'     => 'Número de ordem da linha na visualização da demonstração.'
25
            .' Ordem de apresentação da linha na visualização do registro J150.',
26
            'format'   => ''
27
        ],
28
        'cod_agl' => [
29
            'type'     => 'string',
30
            'regex'    => '^[A-Za-z0-9]$',
31
            'required' => false,
32
            'info'     => 'Código de aglutinação das linhas, atribuído pela pessoa jurídica.',
33
            'format'   => ''
34
        ],
35
        'ind_cod_agl' => [
36
            'type'     => 'string',
37
            'regex'    => '^(T|D)$',
38
            'required' => true,
39
            'info'     => 'Indicador do tipo de código de aglutinação das linhas:'
40
            .' T – Totalizador (nível que totaliza um ou mais níveis inferiores da demonstração financeira)'
41
            .' D – Detalhe (nível mais detalhado da demonstração financeira)',
42
            'format'   => ''
43
        ],
44
        'nivel_agl' => [
45
            'type'     => 'numeric',
46
            'regex'    => '^[0-9]$',
47
            'required' => true,
48
            'info'     => 'Nível do Código de aglutinação (mesmo conceito do plano de contas – Registro I050).',
49
            'format'   => ''
50
        ],
51
        'cod_agl_sup' => [
52
            'type'     => 'string',
53
            'regex'    => '^[A-Za-z0-9]$',
54
            'required' => false,
55
            'info'     => 'Código de aglutinação sintético/grupo de código de aglutinação de nível superior.',
56
            'format'   => ''
57
        ],
58
        'descr_cod_agl' => [
59
            'type'     => 'string',
60
            'regex'    => '^[A-Za-z0-9]$',
61
            'required' => true,
62
            'info'     => 'Descrição do Código de aglutinação.',
63
            'format'   => ''
64
        ],
65
        'vl_cta_ini'    => [
66
            'type'     => 'numeric',
67
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
68
            'required' => false,
69
            'info'     => 'Valor inicial do código de aglutinação no Balanço Patrimonial no exercício '
70
                . 'informado, ou de período definido em norma específica.',
71
            'format'   => '19v2'
72
        ],
73
        'ind_dc_cta_ini' => [
74
            'type'     => 'string',
75
            'regex'    => '^(D|C)$',
76
            'required' => false,
77
            'info'     => 'Indicador da situação do saldo inicial informado no campo anterior: '
78
                . 'D - Devedor; C – Credor.',
79
            'format'   => ''
80
        ],
81
        'vl_cta_fin'    => [
82
            'type'     => 'numeric',
83
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
84
            'required' => true,
85
            'info'     => 'Valor final do código de aglutinação no Balanço Patrimonial no exercício informado, '
86
                .'ou de período definido em norma específica.',
87
            'format'   => '19v2'
88
        ],
89
        'ind_dc_cta_fin' => [
90
            'type'     => 'string',
91
            'regex'    => '^(D|C)$',
92
            'required' => true,
93
            'info'     => 'Indicador da situação do saldo final informado no campo anterior: D - Devedor; C – Credor.',
94
            'format'   => ''
95
        ],
96
        'ind_grp_dre' => [
97
            'type'     => 'string',
98
            'regex'    => '^(D|R)$',
99
            'required' => true,
100
            'info'     => 'Indicador de grupo da DRE:'
101
            .' D – Linha totalizadora ou de detalhe da demonstração que, por sua natureza de despesa, '
102
            .'represente redução do lucro.'
103
            .' R – Linha totalizadora ou de detalhe da demonstração que, por sua natureza de receita, '
104
            .'represente incremento do lucro.',
105
            'format'   => ''
106
        ],
107
        'nota_exp_ref' => [
108
            'type'     => 'string',
109
            'regex'    => '^[A-Za-z0-9]{12}$',
110
            'required' => false,
111
            'info'     => 'Referência a numeração das notas explicativas relativas às demonstrações contábeis.',
112
            'format'   => ''
113
        ]
114
    ];
115
116
    /**
117
     * Constructor
118
     * @param \stdClass $std
119
     */
120
    public function __construct(\stdClass $std)
121
    {
122
        parent::__construct(self::REG);
123
        $this->std = $this->standarize($std);
124
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\J150::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...
125
    }
126
}
127