Completed
Branch master (32b148)
by Edgar
03:11
created

DOMElementWrapper::removeNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
    public function __construct(DOMElement $element)
24
    {
25
        $this->element = $element;
26
    }
27
28
    public function setAttribute($name, $value = null)
29
    {
30
        $this->element->setAttribute($name, $value);
31
    }
32
33
    public function getAttribute($name)
34
    {
35
        return $this->element->getAttribute($name);
36
    }
37
38
    public function setAttributeNS($namespaceURI, $qualifiedName, $value)
39
    {
40
        $this->element->setAttributeNS($namespaceURI, $qualifiedName, $value);
41
    }
42
43
    public function getAttributeNS($namespaceURI, $localName)
44
    {
45
        return $this->element->getAttributeNS($namespaceURI, $localName);
46
    }
47
48
    public function appendChild(XMLDocumentInterface $newNode)
49
    {
50
        $this->element->appendChild($newNode->getElement());
51
    }
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
    public function getElement()
83
    {
84
        return $this->element;
85
    }
86
87
    /**
88
     * @param $value
89
     */
90
    public function setNodeValue($value)
91
    {
92
        $this->element->nodeValue = $value;
93
    }
94
95
    /**
96
     * @inheritdoc
97
     */
98
    public function removeNode(XMLDocumentInterface $child)
99
    {
100
        return $this->element->removeChild($child->getElement());
101
    }
102
}