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

visitAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Dgame\Soap\Visitor;
4
5
use Dgame\Soap\Attribute\Attribute;
6
use Dgame\Soap\Attribute\XmlAttribute;
7
use Dgame\Soap\XmlElement;
8
9
/**
10
 * Class AttributePrefixInheritanceVisitor
11
 * @package Dgame\Soap\Visitor
12
 */
13
final class AttributePrefixInheritanceVisitor implements AttributeVisitorInterface
14
{
15
    /**
16
     * @var XmlElement
17
     */
18
    private $element;
19
20
    /**
21
     * AttributePrefixInheritanceVisitor constructor.
22
     *
23
     * @param XmlElement $element
24
     */
25
    public function __construct(XmlElement $element)
26
    {
27
        $this->element = $element;
28
    }
29
30
    /**
31
     * @param Attribute $attribute
32
     */
33
    public function visitAttribute(Attribute $attribute)
34
    {
35
    }
36
37
    /**
38
     * @param XmlAttribute $attribute
39
     */
40
    public function visitXmlAttribute(XmlAttribute $attribute)
41
    {
42
        $this->inheritPrefix($attribute);
43
    }
44
45
    /**
46
     * @param XmlAttribute $attribute
47
     */
48
    private function inheritPrefix(XmlAttribute $attribute)
49
    {
50
        if (!$this->element->hasPrefix()) {
51
            $this->element->setPrefix($attribute->getName());
52
        }
53
    }
54
}