K300   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 K300 do Bloco K OBRIGATÓRIO [1:1]
11
 * REGISTRO K300: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 */
13
class K300 extends Element implements ElementInterface
14
{
15
    const REG = 'K300';
16
    const LEVEL = 3;
17
    const PARENT = '';
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 consolidada',
25
            'format'   => ''
26
        ],
27
        'val_ag'        => [
28
            'type'     => 'numeric',
29
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
30
            'required' => true,
31
            'info'     => 'Valor absoluto aglutinado',
32
            'format'   => '19v2'
33
        ],
34
        'ind_val_ag' => [
35
            'type'     => 'string',
36
            'regex'    => '^(D|C)$',
37
            'required' => true,
38
            'info'     => 'Indicador da situação do valor aglutinado:'
39
                . ' D – Devedor;'
40
                . ' C – Credor.',
41
            'format'   => ''
42
        ],
43
        'val_el'        => [
44
            'type'     => 'numeric',
45
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
46
            'required' => true,
47
            'info'     => 'Valor absoluto das eliminações',
48
            'format'   => '19v2'
49
        ],
50
        'ind_val_el' => [
51
            'type'     => 'string',
52
            'regex'    => '^(D|C)$',
53
            'required' => true,
54
            'info'     => 'Indicador da situação do valor eliminado:'
55
                . ' D – Devedor;'
56
                . ' C – Credor.',
57
            'format'   => ''
58
        ],
59
        'val_cs'        => [
60
            'type'     => 'numeric',
61
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
62
            'required' => true,
63
            'info'     => 'Valor absoluto consolidado: val_cs = val_ag – val_el',
64
            'format'   => '19v2'
65
        ],
66
        'ind_val_cs' => [
67
            'type'     => 'string',
68
            'regex'    => '^(D|C)$',
69
            'required' => true,
70
            'info'     => 'Indicador da situação do valor consolidado:'
71
                . ' D – Devedor;'
72
                . ' C – Credor.',
73
            'format'   => ''
74
        ]
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\K300::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