Test Failed
Push — master ( 3c2029...7a5756 )
by Randy
02:39
created

XmlNode::disableChildPrefixInheritance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dgame\Soap;
4
5
use Dgame\Soap\Visitor\ElementPrefixInheritanceVisitor;
6
use Dgame\Soap\Visitor\ElementVisitorInterface;
7
8
/**
9
 * Class XmlNode
10
 * @package Dgame\Soap
11
 */
12
class XmlNode extends XmlElement
13
{
14
    /**
15
     * @var Element[]
16
     */
17
    private $elements = [];
18
19
    /**
20
     * @param string $prefix
21
     */
22
    public function setPrefix(string $prefix)
23
    {
24
        parent::setPrefix($prefix);
25 13
26
        $visitor = new ElementPrefixInheritanceVisitor($this);
27 13
        foreach ($this->elements as $element) {
28
            $element->accept($visitor);
29 13
        }
30 4
    }
31
32 13
    /**
33
     * @param Element $element
34
     */
35
    public function appendElement(Element $element)
36
    {
37 13
        $this->elements[] = $element;
38
        $element->accept(new ElementPrefixInheritanceVisitor($this));
39 13
    }
40 13
41 13
    /**
42
     * @return Element[]|XmlNode[]
43
     */
44
    public function getElements(): array
45
    {
46 13
        return $this->elements;
47
    }
48 13
49 6
    /**
50
     * @return bool
51 13
     */
52
    public function hasElements(): bool
53
    {
54
        return !empty($this->elements);
55
    }
56 13
57
    /**
58 13
     * @param ElementVisitorInterface $visitor
59
     */
60
    public function accept(ElementVisitorInterface $visitor)
61
    {
62
        $visitor->visitXmlNode($this);
63
    }
64
}