Z0000   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 112
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 112
loc 112
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace NFePHP\ECF\Elements;
4
5
use NFePHP\ECF\Common\Element;
6
use NFePHP\ECF\Common\ElementInterface;
7
use \stdClass;
8
9
/**
10
 * Elemento 0000 do Bloco 0 OBRIGATÓRIO [1:1]
11
 * REGISTRO 0000: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 */
13 View Code Duplication
class Z0000 extends Element implements ElementInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    const REG = '0000';
16
    const LEVEL = 0;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'NOME_ESC' => [
21
            'type'     => 'string',
22
            'regex'    => '^(LECF)$',
23
            'required' => true,
24
            'info'     => 'Texto fixo contendo LECF.',
25
            'format'   => ''
26
        ],
27
        'COD_VER'     => [
28
            'type'     => 'string',
29
            'regex'    => '^(0006)$',
30
            'required' => true,
31
            'info'     => 'codigo da versao do layout.',
32
            'format'   => ''
33
        ],
34
        'CNPJ'      => [
35
            'type'     => 'string',
36
            'regex'    => '^[0-9]{14}$',
37
            'required' => true,
38
            'info'     => 'Número de inscrição da entidade no CNPJ.',
39
            'format'   => ''
40
        ],
41
        'NOME'      => [
42
            'type'     => 'string',
43
            'regex'    => '^.{2,100}$',
44
            'required' => true,
45
            'info'     => 'Nome empresarial da entidade.',
46
            'format'   => ''
47
        ],
48
        'IND_SIT_INI_PER' => [
49
            'type'     => 'numeric',
50
            'regex'    => '^(0|1|2|3|4)$',
51
            'required' => true,
52
            'info'     => 'Indicador de situação no início do período.',
53
            'format'   => ''
54
        ],
55
        'SIT_ESPECIAL' => [
56
            'type'     => 'numeric',
57
            'regex'    => '^(0|1|2|3|4|5|6|7|8|9)$',
58
            'required' => false,
59
            'info'     => 'Código do Plano de Contas Referencial que será utilizado '
60
                . 'para o mapeamento de todas as contas analíticas',
61
            'format'   => ''
62
        ],
63
        'PAT_REMAN_CIS'    => [
64
            'type'     => 'numeric',
65
            'regex'    => '^\d+(\.\d*)?|\.\d+$',
66
            'required' => true,
67
            'info'     => 'Patrimonio Resmanescente em caso de cisao.',
68
            'format'   => '8v4'
69
        ],
70
        'DT_INI'     => [
71
            'type'     => 'string',
72
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
73
            'required' => true,
74
            'info'     => 'Data inicio do periodo.',
75
            'format'   => ''
76
        ],
77
        'DT_FIN'     => [
78
            'type'     => 'string',
79
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
80
            'required' => true,
81
            'info'     => 'Data final das informações contidas no arquivo.',
82
            'format'   => ''
83
        ],
84
        'RETIFICADORA' => [
85
            'type'     => 'string',
86
            'regex'    => '^(S|N|F)$',
87
            'required' => true,
88
            'info'     => 'Escritora Retificadora.',
89
            'format'   => ''
90
        ],
91
        'NUM_REC' => [
92
            'type'     => 'string',
93
            'regex'    => '^.{0,41}$',
94
            'required' => false,
95
            'info'     => 'Hash do numero do recibo da escrituração anterior.',
96
            'format'   => ''
97
        ],
98
        'TIP_ECF' => [
99
            'type'     => 'numeric',
100
            'regex'    => '^(0|1|2)$',
101
            'required' => true,
102
            'info'     => 'Indicador de tipo de ecf',
103
            'format'   => ''
104
        ],
105
        'COD_SCP'      => [
106
            'type'     => 'string',
107
            'regex'    => '^[0-9]{14}$',
108
            'required' => false,
109
            'info'     => 'Número de inscrição da entidade no CNPJ.',
110
            'format'   => ''
111
        ]
112
    ];
113
114
    /**
115
     * Constructor
116
     * @param \stdClass $std
117
     */
118
    public function __construct(\stdClass $std)
119
    {
120
        parent::__construct(self::REG);
121
        $this->std = $this->standarize($std);
122
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECF\Elements\Z0000::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...
123
    }
124
}
125