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; |
29
|
|
|
|
30
|
|
|
use NFe\Entity\Imposto; |
31
|
|
|
|
32
|
|
|
class Total extends Imposto |
33
|
|
|
{ |
34
|
|
|
|
35
|
30 |
|
public function __construct($total = array()) |
36
|
|
|
{ |
37
|
30 |
|
parent::__construct($total); |
38
|
30 |
|
} |
39
|
|
|
|
40
|
1 |
|
public function toArray($recursive = false) |
41
|
|
|
{ |
42
|
1 |
|
$total = parent::toArray($recursive); |
43
|
1 |
|
return $total; |
44
|
|
|
} |
45
|
|
|
|
46
|
30 |
|
public function fromArray($total = array()) |
47
|
|
|
{ |
48
|
30 |
|
if ($total instanceof Total) { |
49
|
1 |
|
$total = $total->toArray(); |
50
|
30 |
|
} elseif (!is_array($total)) { |
51
|
1 |
|
return $this; |
52
|
|
|
} |
53
|
30 |
|
parent::fromArray($total); |
54
|
30 |
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
2 |
|
public function getNode($name = null) |
58
|
|
|
{ |
59
|
2 |
|
$dom = new \DOMDocument('1.0', 'UTF-8'); |
60
|
2 |
|
$element = $dom->createElement(is_null($name)?'vTotTrib':$name, $this->getTotal(true)); |
61
|
2 |
|
return $element; |
62
|
|
|
} |
63
|
|
|
|
64
|
1 |
|
public function loadNode($element, $name = null) |
65
|
|
|
{ |
66
|
1 |
|
$name = is_null($name)?'vTotTrib':$name; |
67
|
1 |
|
if ($element->nodeName != $name) { |
68
|
|
|
$_fields = $element->getElementsByTagName($name); |
69
|
|
|
if ($_fields->length == 0) { |
70
|
|
|
throw new \Exception('Tag "'.$name.'" não encontrada', 404); |
71
|
|
|
} |
72
|
|
|
$element = $_fields->item(0); |
73
|
|
|
} |
74
|
1 |
|
$this->setBase($element->nodeValue); |
75
|
1 |
|
$this->setAliquota(100); |
76
|
1 |
|
return $element; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|