C425   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 10 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 7
loc 70
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A postValidation() 7 7 2

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\EFD\Elements\ICMSIPI;
4
5
use NFePHP\EFD\Common\Element;
6
use NFePHP\EFD\Common\ElementInterface;
7
use \stdClass;
8
9
class C425 extends Element implements ElementInterface
10
{
11
    const REG = 'C425';
12
    const LEVEL = 5;
13
    const PARENT = 'C420';
14
15
    protected $parameters = [
16
        'COD_ITEM' => [
17
            'type' => 'string',
18
            'regex' => '^.{1,60}$',
19
            'required' => true,
20
            'info' => 'Código do item (campo 02 do Registro 0200)',
21
            'format' => ''
22
        ],
23
        'QTD' => [
24
            'type' => 'numeric',
25
            'regex' => '^\d+(\.\d*)?|\.\d+$',
26
            'required' => true,
27
            'info' => 'Quantidade acumulada do item',
28
            'format' => '15v3'
29
        ],
30
        'UNID' => [
31
            'type' => 'string',
32
            'regex' => '^.{1,6}$',
33
            'required' => true,
34
            'info' => 'Unidade do item (Campo 02 do registro 0190)',
35
            'format' => ''
36
        ],
37
        'VL_ITEM' => [
38
            'type' => 'numeric',
39
            'regex' => '^\d+(\.\d*)?|\.\d+$',
40
            'required' => true,
41
            'info' => 'Valor acumulado do item',
42
            'format' => '15v2'
43
        ],
44
        'VL_PIS' => [
45
            'type' => 'numeric',
46
            'regex' => '^\d+(\.\d*)?|\.\d+$',
47
            'required' => false,
48
            'info' => 'Valor do PIS',
49
            'format' => '15v2'
50
        ],
51
        'VL_COFINS' => [
52
            'type' => 'numeric',
53
            'regex' => '^\d+(\.\d*)?|\.\d+$',
54
            'required' => false,
55
            'info' => 'Valor da COFINS',
56
            'format' => '15v2'
57
        ],
58
    ];
59
60
    /**
61
     * Constructor
62
     * @param \stdClass $std
63
     */
64
    public function __construct(\stdClass $std)
65
    {
66
        parent::__construct(self::REG);
67
        $this->std = $this->standarize($std);
68
        $this->postValidation();
69
    }
70
71 View Code Duplication
    public function postValidation()
0 ignored issues
show
Duplication introduced by
This method 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...
72
    {
73
        if ($this->values->vl_item <= 0) {
74
            throw new \InvalidArgumentException("[" . self::REG . "] " .
75
                " O Valor acumulado do item (VL_ITEM) deve ser maior que 0");
76
        }
77
    }
78
}
79