Completed
Push — master ( 56a459...0ee720 )
by Randy
03:34
created

XmlElement::hasPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dgame\Soap;
4
5
use Dgame\Soap\Hydrator\HydratorInterface;
6
7
/**
8
 * Class XmlElement
9
 * @package Dgame\Soap
10
 */
11
class XmlElement extends Element
12
{
13
    /**
14
     * @var null|string
15
     */
16
    private $prefix;
17
18
    /**
19
     * XmlElement constructor.
20
     *
21
     * @param string      $name
22
     * @param string|null $value
23
     * @param string|null $prefix
24
     */
25
    public function __construct(string $name, string $value = null, string $prefix = null)
26
    {
27
        parent::__construct($name, $value);
28
29
        if ($prefix !== null) {
30
            $this->prefix = $prefix;
31
        }
32
    }
33
34
    /**
35
     * @return null|string
36
     */
37
    final public function getPrefix(): ?string
38
    {
39
        return $this->prefix;
40
    }
41
42
    /**
43
     * @return bool
44
     */
45
    final public function hasPrefix(): bool
46
    {
47
        return $this->prefix !== null;
48
    }
49
50
    /**
51
     * @param string $prefix
52
     */
53
    final public function setPrefix(string $prefix)
54
    {
55
        $prefix = trim($prefix);
56
        if (strlen($prefix) !== 0) {
57
            $this->prefix = $prefix;
58
        }
59
    }
60
61
    /**
62
     * @param HydratorInterface $hydrator
63
     */
64
    public function hydration(HydratorInterface $hydrator)
65
    {
66
        $hydrator->hydrateXmlElement($this);
67
    }
68
}