J930   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 100
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 100
loc 100
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\ECD\Elements;
4
5
use NFePHP\ECD\Common\Element;
6
use NFePHP\ECD\Common\ElementInterface;
7
use \stdClass;
8
9
/**
10
 * Elemento J930 do Bloco J OBRIGATÓRIO [1:1]
11
 * REGISTRO J930: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 *
13
 * OBS.: Fazer verificacao de tamanho do campo ident_cpf_cnpj quando preencher os dados;
14
 */
15 View Code Duplication
class J930 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...
16
{
17
    const REG = 'J930';
18
    const LEVEL = 3;
19
    const PARENT = '';
20
21
    protected $parameters = [
22
        'ident_nom' => [
23
            'type'     => 'string',
24
            'regex'    => '^.{2,100}$',
25
            'required' => true,
26
            'info'     => 'Nome do signatário.',
27
            'format'   => ''
28
        ],
29
        'ident_cpf_cnpj' => [
30
            'type'     => 'numeric',
31
            'regex'    => '^[0-9]{11,14}$',
32
            'required' => true,
33
            'info'     => 'CPF ou CNPJ',
34
            'format'   => ''
35
        ],
36
        'ident_qualif' => [
37
            'type'     => 'string',
38
            'regex'    => '^[0-9]{3}$',
39
            'required' => true,
40
            'info'     => 'Qualificação do assinante, conforme tabela.',
41
            'format'   => ''
42
        ],
43
        'cod_assin' => [
44
            'type'     => 'string',
45
            'regex'    => '^[A-Za-z0-9]{3}$',
46
            'required' => true,
47
            'info'     => 'Código de qualificação do assinante, conforme tabela.',
48
            'format'   => ''
49
        ],
50
        'ind_crc' => [
51
            'type'     => 'string',
52
            'regex'    => '^[A-Za-z0-9]$',
53
            'required' => false,
54
            'info'     => 'Número de inscrição do contabilista no Conselho Regional de Contabilidade.',
55
            'format'   => ''
56
        ],
57
        'email' => [
58
            'type'     => 'string',
59
            'regex'    => '^.{2,250}$',
60
            'required' => false,
61
            'info'     => 'Email do signatário.',
62
            'format'   => ''
63
        ],
64
        'fone' => [
65
            'type'     => 'string',
66
            'regex'    => '^[0-9]{14}$',
67
            'required' => false,
68
            'info'     => 'Telefone do signatário.',
69
            'format'   => ''
70
        ],
71
        'uf_crc' => [
72
            'type'     => 'string',
73
            'regex'    => '^[A-Z]{2}$',
74
            'required' => false,
75
            'info'     => 'Indicação da unidade da federação que expediu o CRC.',
76
            'format'   => ''
77
        ],
78
        'num_seq_crc' => [
79
            'type'     => 'string',
80
            'regex'    => '^[0-9]$',
81
            'required' => false,
82
            'info'     => 'Número da Certidão de Regularidade Profissional do Contador no '
83
                . 'seguinte formato: UF/ano/número',
84
            'format'   => ''
85
        ],
86
        'dt_crc'     => [
87
            'type'     => 'string',
88
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
89
            'required' => false,
90
            'info'     => 'Data de validade da Certidão de Regularidade Profissional do Contador.',
91
            'format'   => ''
92
        ],
93
        'ind_resp_legal' => [
94
            'type'     => 'string',
95
            'regex'    => '^(S|N)$',
96
            'required' => true,
97
            'info'     => 'Identificação do signatário que será validado como '
98
            .' responsável pela assinatura da ECD, conforme atos societários:'
99
            .' S – Sim / N – Não',
100
            'format'   => ''
101
        ]
102
    ];
103
104
    /**
105
     * Constructor
106
     * @param \stdClass $std
107
     */
108
    public function __construct(\stdClass $std)
109
    {
110
        parent::__construct(self::REG);
111
        $this->std = $this->standarize($std);
112
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\J930::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...
113
    }
114
}
115