Completed
Push — master ( 624185...e43015 )
by Roberto
12:57
created

J800::__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 J800 do Bloco J OBRIGATÓRIO [1:1]
11
 * REGISTRO J800: ABERTURA DO ARQUIVO DIGITAL E IDENTIFICAÇÃO DO EMPRESÁRIO OU DA SOCIEDADE EMPRESÁRIA
12
 */
13
class J800 extends Element implements ElementInterface
14
{
15
    const REG = 'J800';
16
    const LEVEL = 3;
17
    const PARENT = '';
18
19
    protected $parameters = [
20
        'tipo_doc' => [
21
            'type'     => 'string',
22
            'regex'    => '^(001|002|003|010|011|012|099)$',
23
            'required' => true,
24
            'info'     => 'Tipo de documento:'
25
            .' 001: Demonstração do Resultado Abrangente do Período'
26
            .' 002: Demonstração dos Fluxos de Caixa'
27
            .' 003: Demonstração do Valor Adicionado'
28
            .' 010: Notas Explicativas'
29
            .' 011: Relatório da Administração'
30
            .' 012: Parecer dos Auditores'
31
            .' 099: Outros',
32
            'format'   => ''
33
        ],
34
        'desc_rtf' => [
35
            'type'     => 'string',
36
            'regex'    => '^[A-Za-z0-9]$',
37
            'required' => false,
38
            'info'     => 'Descrição do arquivo .rtf.',
39
            'format'   => ''
40
        ],
41
        'hash_rtf' => [
42
            'type'     => 'string',
43
            'regex'    => '^.{1,40}$',
44
            'required' => false,
45
            'info'     => 'Hash do arquivo .rtf incluído.',
46
            'format'   => ''
47
        ],
48
        'arq_rtf' => [
49
            'type'     => 'string',
50
            'regex'    => '^[A-Za-z0-9]$',
51
            'required' => true,
52
            'info'     => 'Sequência de bytes que representem um único arquivo no formato RTF (Rich Text Format).',
53
            'format'   => ''
54
        ],
55
        'ind_fim_rtf' => [
56
            'type'     => 'string',
57
            'regex'    => '^(J800FIM)$',
58
            'required' => true,
59
            'info'     => 'Indicador de fim do arquivo RTF. Texto fixo contendo J800FIM.',
60
            'format'   => ''
61
        ]
62
    ];
63
64
    /**
65
     * Constructor
66
     * @param \stdClass $std
67
     */
68
    public function __construct(\stdClass $std)
69
    {
70
        parent::__construct(self::REG);
71
        $this->std = $this->standarize($std);
72
        $this->postValidation();
0 ignored issues
show
Unused Code introduced by
The call to the method NFePHP\ECD\Elements\J800::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...
73
    }
74
}
75