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

AttributePrefixInheritanceVisitor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A visitAttribute() 0 3 1
A visitXmlAttribute() 0 4 1
A inheritPrefix() 0 6 2
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
}