Completed
Push — master ( df7a74...493c6b )
by Roberto
15:39 queued 23s
created

I053::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
dl 6
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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 I053 do Bloco I OBRIGATÓRIO [0:N]
11
 * REGISTRO I053: SUBCONTAS CORRELATAS
12
 */
13 View Code Duplication
class I053 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 = 'I053';
16
    const LEVEL = 4;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'cod_idt'     => [
21
            'type'     => 'string',
22
            'regex'    => '^[A-Za-z0-9]{6}$',
23
            'required' => true,
24
            'info'     => 'Codigo de identificacao do grupo de conta-subcontas.',
25
            'format'   => ''
26
        ],
27
        'cod_cnt_corr'  => [
28
            'type'     => 'string',
29
            'regex'    => '^[A-Za-z0-9]$',
30
            'required' => true,
31
            'info'     => 'Código da subconta correlata (deve estar no plano de contas '
32
                . 'e só pode estar relacionada a um único grupo)',
33
            'format'   => ''
34
        ],
35
        'nat_sub_cnt'  => [
36
            'type'     => 'string',
37
            'regex'    => '^[A-Za-z0-9]{2}$',
38
            'required' => true,
39
            'info'     => 'Natureza da subconta correlata (conforme tabela de '
40
                . 'natureza da subconta publicada no Sped )',
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\I053::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