Code Duplication    Length = 58-58 lines in 2 locations

src/Attribute/XmlAttribute.php 1 location

@@ 12-69 (lines=58) @@
9
 * Class XmlAttribute
10
 * @package Dgame\Soap\Attribute
11
 */
12
class XmlAttribute extends Attribute implements PrefixableInterface
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
}

src/XmlElement.php 1 location

@@ 11-68 (lines=58) @@
8
 * Class XmlElement
9
 * @package Dgame\Soap
10
 */
11
class XmlElement extends Element implements PrefixableInterface
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->setPrefix($prefix);
31
        }
32
    }
33
34
    /**
35
     * @return 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 VisitorInterface $hydrator
63
     */
64
    public function accept(VisitorInterface $hydrator)
65
    {
66
        $hydrator->visitXmlElement($this);
67
    }
68
}