I250::__construct()   A
last analyzed

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 I250 do Bloco I OBRIGATÓRIO [1:1]
11
 * REGISTRO I250: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 *
13
 * Alterar campos: vl_dc / vl_dc_mf
14
 */
15
class I250 extends Element implements ElementInterface
16
{
17
    const REG = 'I250';
18
    const LEVEL = 4;
19
    const PARENT = '';
20
21
    protected $parameters = [
22
        'cod_cta'  => [
23
            'type'     => 'string',
24
            'regex'    => '^.*$',
25
            'required' => true,
26
            'info'     => 'Código da conta analitica',
27
            'format'   => ''
28
        ],
29
        'cod_ccus' => [
30
            'type'     => 'string',
31
            'regex'    => '^[A-Za-z0-9]$',
32
            'required' => false,
33
            'info'     => 'Código do centro de custos.',
34
            'format'   => ''
35
        ],
36
        'vl_dc'     => [
37
            'type'     => 'numeric',
38
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
39
            'required' => true,
40
            'info'     => 'Valor da partida.',
41
            'format'   => '19v2'
42
        ],
43
        'ind_dc' => [
44
            'type'     => 'string',
45
            'regex'    => '^(D|C)$',
46
            'required' => true,
47
            'info'     => 'Indicador da situação do saldo final: D - Devedor; C - Credor.',
48
            'format'   => ''
49
        ],
50
        'num_arq' => [
51
            'type'     => 'string',
52
            'regex'    => '^[0-9]$',
53
            'required' => false,
54
            'info'     => 'Número, Código ou caminho de localização dos documentos arquivados.',
55
            'format'   => ''
56
        ],
57
        'cod_hist_pad' => [
58
            'type'     => 'string',
59
            'regex'    => '^([0-9])*$',
60
            'required' => false,
61
            'info'     => 'Código do histórico padronizado, conforme tabela I075.',
62
            'format'   => ''
63
        ],
64
        'hist' => [
65
            'type'     => 'string',
66
            'regex'    => '^[A-Za-z0-9]{65535}$',
67
            'required' => false,
68
            'info'     => 'Código do histórico padronizado, conforme tabela I075.',
69
            'format'   => ''
70
        ],
71
        'cod_part' => [
72
            'type'     => 'string',
73
            'regex'    => '^[A-Za-z0-9]$',
74
            'required' => false,
75
            'info'     => 'Código do histórico padronizado, conforme tabela I075.',
76
            'format'   => ''
77
        ]
78
    ];
79
80
    // ,
81
    // 'vl_dc_mf'     => [
82
    //     'type'     => 'string',
83
    //     'regex'    => '^[0-9]{19}$',
84
    //     'required' => false,
85
    //     'info'     => 'Valor da partida em moeda funcional, convertido para reais.',
86
    //     'format'   => ''
87
    // ],
88
    // 'ind_dc_mf' => [
89
    //     'type'     => 'string',
90
    //     'regex'    => '^(D|C)$',
91
    //     'required' => false,
92
    //     'info'     => 'Indicador da natureza da partida em moeda funcional: D - Devedor; C - Credor.',
93
    //     'format'   => ''
94
    // ]
95
96
    /**
97
     * Constructor
98
     * @param \stdClass $std
99
     */
100
    public function __construct(\stdClass $std)
101
    {
102
        parent::__construct(self::REG);
103
        $this->std = $this->standarize($std);
104
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\I250::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...
105
    }
106
}
107