DOMElementInjection::inject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
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