Completed
Push — master ( aa6cd0...7372cb )
by Randy
02:05
created

XmlAttribute::hasPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dgame\Soap\Attribute;
4
5
use Dgame\Soap\Hydrator\VisitorInterface;
6
use Dgame\Soap\PrefixableInterface;
7
8
/**
9
 * Class XmlAttribute
10
 * @package Dgame\Soap\Attribute
11
 */
12 View Code Duplication
class XmlAttribute extends Attribute implements PrefixableInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var null|string
16
     */
17
    private $prefix;
18
19
    /**
20
     * XmlAttribute constructor.
21
     *
22
     * @param string      $name
23
     * @param string|null $value
24
     * @param string|null $prefix
25
     */
26
    public function __construct(string $name, string $value = null, string $prefix = null)
27
    {
28
        parent::__construct($name, $value);
29
30
        if ($prefix !== null) {
31
            $this->setPrefix($prefix);
32
        }
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    final public function getPrefix(): string
39
    {
40
        return $this->prefix;
41
    }
42
43
    /**
44
     * @param string $prefix
45
     */
46
    final public function setPrefix(string $prefix)
47
    {
48
        $prefix = trim($prefix);
49
        if (strlen($prefix) !== 0) {
50
            $this->prefix = $prefix;
51
        }
52
    }
53
54
    /**
55
     * @return bool
56
     */
57
    final public function hasPrefix(): bool
58
    {
59
        return $this->prefix !== null;
60
    }
61
62
    /**
63
     * @param VisitorInterface $hydrator
64
     */
65
    public function accept(VisitorInterface $hydrator)
66
    {
67
        $hydrator->visitXmlAttribute($this);
68
    }
69
}