J935   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 41
loc 41
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 J935 do Bloco J OBRIGATÓRIO [1:1]
11
 * REGISTRO J935: 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_t quando preencher os dados;
14
 */
15 View Code Duplication
class J935 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 = 'J935';
18
    const LEVEL = 3;
19
    const PARENT = '';
20
21
    protected $parameters = [
22
        'ni_cpf_cnpj' => [
23
            'type'     => 'numeric',
24
            'regex'    => '^[0-9]$',
25
            'required' => true,
26
            'info'     => 'CPF do auditor independente/CNPJ da pessoa jurídica de auditoria independente.',
27
            'format'   => ''
28
        ],
29
        'nome_auditor_firma' => [
30
            'type'     => 'string',
31
            'regex'    => '^[A-Za-z]$',
32
            'required' => true,
33
            'info'     => 'Nome do auditor independente ou pessoa jurídica de auditoria independente.',
34
            'format'   => ''
35
        ],
36
        'cod_assin_t' => [
37
            'type'     => 'string',
38
            'regex'    => '^[A-Za-z0-9]{3}$',
39
            'required' => false,
40
            'info'     => 'Registro do auditor independente na CVM.',
41
            'format'   => ''
42
        ]
43
    ];
44
45
    /**
46
     * Constructor
47
     * @param \stdClass $std
48
     */
49
    public function __construct(\stdClass $std)
50
    {
51
        parent::__construct(self::REG);
52
        $this->std = $this->standarize($std);
53
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\J935::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...
54
    }
55
}
56