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

I012::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
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 I012 do Bloco I OBRIGATÓRIO [1:N]
11
 * REGISTRO I012: LIVROS AUXILIARES AO DIÁRIO OU LIVRO PRINCIPAL
12
 */
13
class I012 extends Element implements ElementInterface
14
{
15
    const REG = 'I012';
16
    const LEVEL = 3;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'num_ord'    => [
21
            'type'     => 'numeric',
22
            'regex'    => '^([1-9][0-9]*)$',
23
            'required' => true,
24
            'info'     => 'Número de ordem do instrumento associado.',
25
            'format'   => ''
26
        ],
27
        'nat_liv' => [
28
            'type'     => 'string',
29
            'regex'    => '^[A-Za-z0-9]{80}$',
30
            'required' => true,
31
            'info'     => 'Natureza do livro associado; finalidade a que se destina o instrumento.',
32
            'format'   => ''
33
        ],
34
        'tipo' => [
35
            'type'     => 'numeric',
36
            'regex'    => '^[0-1]{1}$',
37
            'required' => true,
38
            'info'     => '0 - Bloco com dados informados;1- Bloco sem dados informados.',
39
            'format'   => ''
40
        ],
41
        'cod_hash_aux' => [
42
            'type'     => 'string',
43
            'regex'    => '^.{1,40}$',
44
            'required' => false,
45
            'info'     => 'Código Hash do arquivo correspondente ao livro auxiliar utilizado na assinatura digital.',
46
            'format'   => ''
47
        ]
48
    ];
49
50
    /**
51
     * Constructor
52
     * @param \stdClass $std
53
     */
54
    public function __construct(\stdClass $std)
55
    {
56
        parent::__construct(self::REG);
57
        $this->std = $this->standarize($std);
58
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\I012::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...
59
    }
60
}
61