J210   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 81
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 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 J210 do Bloco J OBRIGATÓRIO [1:1]
11
 * REGISTRO J210: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 */
13
class J210 extends Element implements ElementInterface
14
{
15
    const REG = 'J210';
16
    const LEVEL = 3;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'ind_tip' => [
21
            'type'     => 'numeric',
22
            'regex'    => '^[0-1]{1}$',
23
            'required' => true,
24
            'info'     => 'Indicador do tipo de demonstração:'
25
            .' 0 – DLPA – Demonstração de Lucro ou Prejuízos Acumulados'
26
            .' 1 – DMPL – Demonstração de Mutações do Patrimônio Líquido',
27
            'format'   => ''
28
        ],
29
        'cod_agl' => [
30
            'type'     => 'string',
31
            'regex'    => '^[A-Za-z0-9]$',
32
            'required' => true,
33
            'info'     => 'Código de aglutinação atribuído pela pessoa jurídica.',
34
            'format'   => ''
35
        ],
36
        'descr_cod_agl' => [
37
            'type'     => 'string',
38
            'regex'    => '^[A-Za-z0-9]$',
39
            'required' => true,
40
            'info'     => 'Descrição do código de aglutinação.',
41
            'format'   => ''
42
        ],
43
        'vl_cta_ini'    => [
44
            'type'     => 'numeric',
45
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
46
            'required' => true,
47
            'info'     => 'Valor inicial do código de aglutinação no Balanço Patrimonial no exercício '
48
                . 'informado, ou de período definido em norma específica.',
49
            'format'   => '19v2'
50
        ],
51
        'ind_dc_cta_ini' => [
52
            'type'     => 'string',
53
            'regex'    => '^(D|C)$',
54
            'required' => true,
55
            'info'     => 'Indicador da situação do saldo inicial informado no campo anterior: '
56
                . 'D - Devedor; C – Credor.',
57
            'format'   => ''
58
        ],
59
        'vl_cta_fin'    => [
60
            'type'     => 'numeric',
61
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
62
            'required' => true,
63
            'info'     => 'Valor final do código de aglutinação no Balanço Patrimonial no exercício informado, '
64
                . 'ou de período definido em norma específica.',
65
            'format'   => '19v2'
66
        ],
67
        'ind_dc_cta_fin' => [
68
            'type'     => 'string',
69
            'regex'    => '^(D|C)$',
70
            'required' => true,
71
            'info'     => 'Indicador da situação do saldo final informado no campo anterior: D - Devedor; C – Credor.',
72
            'format'   => ''
73
        ],
74
        'nota_exp_ref' => [
75
            'type'     => 'string',
76
            'regex'    => '^[A-Za-z0-9]{12}$',
77
            'required' => false,
78
            'info'     => 'Referência a numeração das notas explicativas relativas às demonstrações contábeis.',
79
            'format'   => ''
80
        ]
81
    ];
82
83
    /**
84
     * Constructor
85
     * @param \stdClass $std
86
     */
87
    public function __construct(\stdClass $std)
88
    {
89
        parent::__construct(self::REG);
90
        $this->std = $this->standarize($std);
91
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\J210::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...
92
    }
93
}
94