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

I155::__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 I155 do Bloco I OBRIGATÓRIO [0:N]
11
 * REGISTRO I155: DETALHE DOS SALDOS PERIÓDICOS
12
 */
13
class I155 extends Element implements ElementInterface
14
{
15
    const REG = 'I155';
16
    const LEVEL = 4;
17
    const PARENT = 'I150';
18
19
    protected $parameters = [
20
        'cod_cta'  => [
21
            'type'     => 'string',
22
            'regex'    => '^[A-Za-z0-9]$',
23
            'required' => true,
24
            'info'     => 'Código da conta analitica',
25
            'format'   => ''
26
        ],
27
        'cod_ccus'  => [
28
            'type'     => 'string',
29
            'regex'    => '^[A-Za-z0-9]$',
30
            'required' => false,
31
            'info'     => 'Código do Centro de Custos',
32
            'format'   => ''
33
        ],
34
        'vl_sld_ini'    => [
35
            'type'     => 'numeric',
36
            'regex'    => '^[0-9]{19}$',
37
            'required' => true,
38
            'info'     => 'Código  do  município  do  domicílio  fiscal  da  '
39
            . 'entidade, conforme a tabela IBGE',
40
            'format'   => ''
41
        ],
42
        'ind_dc_ini' => [
43
            'type'     => 'string',
44
            'regex'    => '^[D-C]{1}$',
45
            'required' => false,
46
            'info'     => 'Indicador da situacao do saldo inicial: D-Devedor; C-Credor',
47
            'format'   => ''
48
        ],
49
        'vl_deb'    => [
50
            'type'     => 'numeric',
51
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
52
            'required' => true,
53
            'info'     => 'Valor total dos debitos no periodo',
54
            'format'   => '19v2'
55
        ],
56
        'vl_cred'    => [
57
            'type'     => 'numeric',
58
            'regex'    => '^[0-9]{19}$',
59
            'required' => true,
60
            'info'     => 'Valor total dos creditos no periodo',
61
            'format'   => ''
62
        ],
63
        'vl_sld_fin'    => [
64
            'type'     => 'numeric',
65
            'regex'    => '^[0-9]{19}$',
66
            'required' => true,
67
            'info'     => 'Valor total dos creditos no periodo',
68
            'format'   => ''
69
        ],
70
        'ind_dc_fin' => [
71
            'type'     => 'string',
72
            'regex'    => '^[D-C]{1}$',
73
            'required' => false,
74
            'info'     => 'Indicador da situacao do saldo final: D-Devedor; C-Credor',
75
            'format'   => ''
76
        ]
77
    ];
78
79
    /**
80
     * Constructor
81
     * @param \stdClass $std
82
     */
83
    public function __construct(\stdClass $std)
84
    {
85
        parent::__construct(self::REG);
86
        $this->std = $this->standarize($std);
87
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\I155::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...
88
    }
89
}
90