1
|
|
|
<?php |
2
|
|
|
namespace nstdio\svg\xml; |
3
|
|
|
use DOMElement; |
4
|
|
|
use nstdio\svg\traits\ElementTrait; |
5
|
|
|
use nstdio\svg\XMLDocumentInterface; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class DOMElementWrapper |
9
|
|
|
* |
10
|
|
|
* @package nstdio\svg\xml |
11
|
|
|
* @author Edgar Asatryan <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class DOMElementWrapper implements XMLDocumentInterface |
14
|
|
|
{ |
15
|
|
|
use ElementTrait; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var DOMElement |
19
|
|
|
*/ |
20
|
|
|
private $element; |
21
|
|
|
|
22
|
|
|
|
23
|
119 |
|
public function __construct(DOMElement $element) |
24
|
|
|
{ |
25
|
119 |
|
$this->element = $element; |
26
|
119 |
|
} |
27
|
|
|
|
28
|
119 |
|
public function setAttribute($name, $value = null) |
29
|
|
|
{ |
30
|
119 |
|
$this->element->setAttribute($name, $value); |
31
|
119 |
|
} |
32
|
|
|
|
33
|
88 |
|
public function getAttribute($name) |
34
|
|
|
{ |
35
|
88 |
|
return $this->element->getAttribute($name); |
36
|
|
|
} |
37
|
|
|
|
38
|
119 |
|
public function setAttributeNS($namespaceURI, $qualifiedName, $value) |
39
|
|
|
{ |
40
|
119 |
|
$this->element->setAttributeNS($namespaceURI, $qualifiedName, $value); |
41
|
119 |
|
} |
42
|
|
|
|
43
|
69 |
|
public function getAttributeNS($namespaceURI, $localName) |
44
|
|
|
{ |
45
|
69 |
|
return $this->element->getAttributeNS($namespaceURI, $localName); |
46
|
|
|
} |
47
|
|
|
|
48
|
58 |
|
public function appendChild(XMLDocumentInterface $newNode) |
49
|
|
|
{ |
50
|
58 |
|
$this->element->appendChild($newNode->getElement()); |
51
|
58 |
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param $name |
55
|
|
|
* @param null $value |
56
|
|
|
* |
57
|
|
|
* @return XMLDocumentInterface A new element. |
58
|
|
|
*/ |
59
|
|
|
public function createElement($name, $value = null) |
60
|
|
|
{ |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function createElementNS($namespaceURI, $qualifiedName, $value = null) |
65
|
|
|
{ |
66
|
|
|
throw NotImplementedException::newInstance(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function saveHTML() |
70
|
|
|
{ |
71
|
|
|
// TODO: Implement saveHTML() method. |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return bool |
76
|
|
|
*/ |
77
|
|
|
public static function isLoaded() |
78
|
|
|
{ |
79
|
|
|
return DOMWrapper::isLoaded(); |
80
|
|
|
} |
81
|
|
|
|
82
|
119 |
|
public function getElement() |
83
|
|
|
{ |
84
|
119 |
|
return $this->element; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @inheritdoc |
89
|
|
|
*/ |
90
|
1 |
|
public function setNodeValue($value) |
91
|
|
|
{ |
92
|
1 |
|
$this->element->nodeValue = $value; |
93
|
1 |
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @inheritdoc |
98
|
|
|
*/ |
99
|
1 |
|
public function getNodeValue() |
100
|
|
|
{ |
101
|
1 |
|
return $this->element->nodeValue; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @inheritdoc |
106
|
|
|
*/ |
107
|
1 |
|
public function removeNode(XMLDocumentInterface $child) |
108
|
|
|
{ |
109
|
1 |
|
return $this->element->removeChild($child->getElement()); |
110
|
|
|
} |
111
|
|
|
} |