XmlNode   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 4
dl 0
loc 50
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setPrefix() 0 9 2
A appendElement() 0 5 1
A hasElements() 0 4 1
A getElements() 0 4 1
A accept() 0 4 1
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
    public function setPrefix(string $prefix)
20
    {
21
        parent::setPrefix($prefix);
22 15
23
        $visitor = new ElementPrefixInheritanceVisitor($this);
24 15
        foreach ($this->elements as $element) {
25
            $element->accept($visitor);
26 15
        }
27 15
    }
28 4
29
    /**
30 15
     * @param Element $element
31
     */
32
    final public function appendElement(Element $element)
33
    {
34
        $this->elements[] = $element;
35 15
        $element->accept(new ElementPrefixInheritanceVisitor($this));
36
    }
37 15
38 15
    /**
39 15
     * @return bool
40
     */
41
    final public function hasElements(): bool
42
    {
43
        return !empty($this->elements);
44 15
    }
45
46 15
    /**
47
     * @return Element[]
48
     */
49
    final public function getElements(): array
50
    {
51
        return $this->elements;
52 2
    }
53
54 2
    /**
55
     * @param ElementVisitorInterface $visitor
56
     */
57
    public function accept(ElementVisitorInterface $visitor)
58
    {
59
        $visitor->visitXmlNode($this);
60
    }
61
}