DOMElementInjection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A inject() 0 4 1
A __construct() 0 5 1
1
<?php
2
3
namespace Raigu\XRoad\SoapEnvelope\Element;
4
5
use DOMDocument;
6
use DOMElement;
7
8
/**
9
 * I append DOMElement as child to referred node.
10
 */
11
final class DOMElementInjection implements XmlInjectable
12
{
13
    /**
14
     * @var string
15
     */
16
    private $parentNS;
17
    /**
18
     * @var string
19
     */
20
    private $parentTagName;
21
    /**
22
     * @var DOMElement
23
     */
24
    private $child;
25
26 1
    public function inject(DOMDocument $dom): void
27
    {
28 1
        $elements = $dom->getElementsByTagNameNS($this->parentNS, $this->parentTagName);
29 1
        $elements->item(0)->appendChild($this->child);
30 1
    }
31
32 1
    public function __construct(string $parentNS, string $parentTagName, DOMElement $child)
33
    {
34 1
        $this->parentNS = $parentNS;
35 1
        $this->parentTagName = $parentTagName;
36 1
        $this->child = $child;
37 1
    }
38
}
39