K110::__construct()   A
last analyzed

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 K110 do Bloco K OBRIGATÓRIO [1:1]
11
 * REGISTRO K110: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 */
13
class K110 extends Element implements ElementInterface
14
{
15
    const REG = 'K110';
16
    const LEVEL = 4;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'evento' => [
21
            'type'     => 'numeric',
22
            'regex'    => '^(1|2|3|4|5|6|7|8)$',
23
            'required' => true,
24
            'info'     => 'Evento societário ocorrido no período:'
25
            .' 1 – Aquisição'
26
            .' 2 – Alienação'
27
            .' 3 – Fusão'
28
            .' 4 – Cisão Parcial'
29
            .' 5 – Cisão Total'
30
            .' 6 – Incorporação'
31
            .' 7 – Extinção'
32
            .' 8 – Constituição',
33
            'format'   => ''
34
        ],
35
        'dt_evento'     => [
36
            'type'     => 'string',
37
            'regex'    => '^(0[1-9]|[1-2][0-9]|31(?!(?:0[2469]|11))|30(?!02))(0[1-9]|1[0-2])([12]\d{3})$',
38
            'required' => true,
39
            'info'     => 'Data do evento societário.',
40
            'format'   => ''
41
        ]
42
    ];
43
44
    /**
45
     * Constructor
46
     * @param \stdClass $std
47
     */
48
    public function __construct(\stdClass $std)
49
    {
50
        parent::__construct(self::REG);
51
        $this->std = $this->standarize($std);
52
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\K110::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...
53
    }
54
}
55