Completed
Push — master ( 7902ae...947943 )
by Edgar
03:20
created

DOMElementWrapper   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 75.76%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 14
c 3
b 0
f 1
lcom 1
cbo 4
dl 0
loc 99
ccs 25
cts 33
cp 0.7576
rs 10

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setAttribute() 0 4 1
A getAttribute() 0 4 1
A setAttributeNS() 0 4 1
A getAttributeNS() 0 4 1
A appendChild() 0 4 1
A createElement() 0 4 1
A createElementNS() 0 4 1
A saveHTML() 0 4 1
A isLoaded() 0 4 1
A getElement() 0 4 1
A setNodeValue() 0 4 1
A getNodeValue() 0 4 1
A removeNode() 0 4 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 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
}