Test Failed
Push — master ( e53a66...43458c )
by Francimar
16:26
created

Integral::loadNode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * MIT License
4
 *
5
 * Copyright (c) 2016 MZ Desenvolvimento de Sistemas LTDA
6
 *
7
 * @author Francimar Alves <[email protected]>
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to deal
11
 * in the Software without restriction, including without limitation the rights
12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 * copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in all
17
 * copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
 * SOFTWARE.
26
 *
27
 */
28
namespace NFe\Entity\Imposto\ICMS;
29
30
use NFe\Common\Util;
31
32
/**
33
 * Tributação pelo ICMS
34
 * 00 - Tributada integralmente, estende de Normal
35
 */
36
class Integral extends Normal
37
{
38
39 5
    public function __construct($integral = [])
40
    {
41 5
        parent::__construct($integral);
42 5
    }
43
    
44
    /**
45
     * Altera o valor do Fundo para o informado no parâmetro
46
     * interceptando a alteração do fundo para aplicar a base integral
47
     * @param mixed $fundo novo valor para Fundo
48
     * @return Base A própria instância da classe
49
     */
50 5
    public function setFundo($fundo)
51
    {
52 5
        parent::setFundo($fundo);
53 5
        if (!is_null($this->getFundo())) {
54 5
            $this->getFundo()->setBase($this->getBase());
55
        }
56 5
        return $this;
57
    }
58
59
    /**
60
     * Altera o valor do Base para o informado no parâmetro
61
     * interceptando a alteração do base para aplicar a base integral no fundo
62
     * @param mixed $base novo valor para Base
63
     * @return Imposto A própria instância da classe
64
     */
65 5
    public function setBase($base)
66
    {
67 5
        parent::setBase($base);
68 5
        if (!is_null($this->getFundo())) {
69 4
            $this->getFundo()->setBase($this->getBase());
70
        }
71 5
        return $this;
72
    }
73
74 2
    public function toArray($recursive = false)
75
    {
76 2
        $integral = parent::toArray($recursive);
77 2
        return $integral;
78
    }
79
80 5
    public function fromArray($integral = [])
81
    {
82 5
        if ($integral instanceof Integral) {
83 2
            $integral = $integral->toArray();
84 5
        } elseif (!is_array($integral)) {
85 2
            return $this;
86
        }
87 5
        parent::fromArray($integral);
88 5
        if (!isset($integral['tributacao'])) {
89 5
            $this->setTributacao('00');
90
        }
91 5
        return $this;
92
    }
93
94 4
    public function getNode($name = null)
95
    {
96 4
        $element = parent::getNode(is_null($name)?'ICMS00':$name);
97 4
        if (Util::nodeExists($element, 'vBCFCP')) {
98 2
            $node = Util::findNode($element, 'vBCFCP');
99 2
            $node->parentNode->removeChild($node);
100
        }
101 4
        return $element;
102
    }
103
104 2
    public function loadNode($element, $name = null)
105
    {
106 2
        $name = is_null($name)?'ICMS00':$name;
107 2
        $element = parent::loadNode($element, $name);
108 2
        return $element;
109
    }
110
}
111