I200::__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 I200 do Bloco I OBRIGATÓRIO [0:N]
11
 * REGISTRO I200: LANÇAMENTO CONTÁBIL
12
 */
13
class I200 extends Element implements ElementInterface
14
{
15
    const REG = 'I200';
16
    const LEVEL = 3;
17
    const PARENT = 'I010';
18
19
    protected $parameters = [
20
        'num_lcto'      => [
21
            'type'     => 'string',
22
            'regex'    => '^[0-9]*$',
23
            'required' => true,
24
            'info'     => 'Número ou Código de identificação único do lançamento contábil.',
25
            'format'   => ''
26
        ],
27
        'dt_lcto'     => [
28
            'type'     => 'string',
29
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
30
            'required' => true,
31
            'info'     => 'Data do lançamento.',
32
            'format'   => ''
33
        ],
34
        'vl_lcto'     => [
35
            'type'     => 'numeric',
36
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
37
            'required' => true,
38
            'info'     => 'Valor do lancamento.',
39
            'format'   => '19v2'
40
        ],
41
        'ind_lcto' => [
42
            'type'     => 'string',
43
            'regex'    => '^(N|E)$',
44
            'required' => true,
45
            'info'     => 'Indicador do tipo de lançamento: '
46
                . 'N - Lançamento normal (todos os lançamentos, exceto os de encerramento das contas de resultado); '
47
                . 'E - Lançamento de encerramento de contas de resultado. '
48
                . 'X – Lançamento extemporâneo.',
49
            'format'   => ''
50
        ],
51
        'dt_lcto_ext'     => [
52
            'type'     => 'string',
53
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
54
            'required' => false,
55
            'info'     => 'Data de ocorrência dos fatos objeto do lançamento extemporâneo.',
56
            'format'   => ''
57
        ]
58
    ];
59
60
    // ,
61
    //     'vl_lcto_mf'     => [
62
    //         'type'     => 'string',
63
    //         'regex'    => '^[0-9]{19}$',
64
    //         'required' => false,
65
    //         'info'     => 'Valor do lançamento em moeda funcional, convertido para reais.',
66
    //         'format'   => ''
67
    //     ]
68
69
    /**
70
     * Constructor
71
     * @param \stdClass $std
72
     */
73
    public function __construct(\stdClass $std)
74
    {
75
        parent::__construct(self::REG);
76
        $this->std = $this->standarize($std);
77
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\I200::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...
78
    }
79
}
80