I155   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 76
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 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'    => '^.*$',
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'    => '^\d+(\.\d*)?|\.\d+$',
37
            'required' => true,
38
            'info'     => 'Valor do saldo inicial do período.',
39
            'format'   => '19v2'
40
        ],
41
        'ind_dc_ini' => [
42
            'type'     => 'string',
43
            'regex'    => '^(D|C)$',
44
            'required' => false,
45
            'info'     => 'Indicador da situacao do saldo inicial: D-Devedor; C-Credor',
46
            'format'   => ''
47
        ],
48
        'vl_deb'    => [
49
            'type'     => 'numeric',
50
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
51
            'required' => true,
52
            'info'     => 'Valor total dos debitos no periodo',
53
            'format'   => '19v2'
54
        ],
55
        'vl_cred'    => [
56
            'type'     => 'numeric',
57
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
58
            'required' => true,
59
            'info'     => 'Valor total dos creditos no periodo',
60
            'format'   => '19v2'
61
        ],
62
        'vl_sld_fin'    => [
63
            'type'     => 'numeric',
64
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
65
            'required' => true,
66
            'info'     => 'Valor total dos creditos no periodo',
67
            'format'   => '19v2'
68
        ],
69
        'ind_dc_fin' => [
70
            'type'     => 'string',
71
            'regex'    => '^(D|C)$',
72
            'required' => false,
73
            'info'     => 'Indicador da situacao do saldo final: D-Devedor; C-Credor',
74
            'format'   => ''
75
        ]
76
    ];
77
78
    /**
79
     * Constructor
80
     * @param \stdClass $std
81
     */
82
    public function __construct(\stdClass $std)
83
    {
84
        parent::__construct(self::REG);
85
        $this->std = $this->standarize($std);
86
        $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...
87
    }
88
}
89