Passed
Push — master ( 335c74...ca5aae )
by Pierre
02:52
created

POA::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class POA implements NodeInterface
10
{
11
    const POA_ONE_TIME = '1'; // One Time POA
12
    const POA_BLANKET  = '2'; // Blanket POA
13
14
    /**
15
     * @var string
16
     */
17
    private $code;
18
19
    /**
20
     * @var string
21
     */
22
    private $description;
23
24
    /**
25
     * @param null|object $attributes
26
     */
27 View Code Duplication
    public function __construct($attributes = null)
0 ignored issues
show
Duplication introduced by
This method 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...
28
    {
29
        if (null !== $attributes) {
30
            if (isset($attributes->Code)) {
31
                $this->setCode($attributes->Code);
32
            }
33
            if (isset($attributes->Description)) {
34
                $this->setDescription($attributes->Description);
35
            }
36
        }
37
    }
38
39
    /**
40
     * @param null|DOMDocument $document
41
     *
42
     * @return DOMElement
43
     */
44 View Code Duplication
    public function toNode(DOMDocument $document = null)
0 ignored issues
show
Duplication introduced by
This method 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...
45
    {
46
        if (null === $document) {
47
            $document = new DOMDocument();
48
        }
49
50
        $node = $document->createElement('POA');
51
52
        $code = $this->getCode();
53
        if (isset($code)) {
54
            $node->appendChild($document->createElement('Code', $code));
55
        }
56
57
        $description = $this->getDescription();
58
        if (isset($description)) {
59
            $node->appendChild($document->createElement('Description', $description));
60
        }
61
62
        return $node;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getCode()
69
    {
70
        return $this->code;
71
    }
72
73
    /**
74
     * @param string $code
75
     *
76
     * @return $this
77
     */
78
    public function setCode($code)
79
    {
80
        $this->code = $code;
81
82
        return $this;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getDescription()
89
    {
90
        return $this->description;
91
    }
92
93
    /**
94
     * @param string $description
95
     *
96
     * @return $this
97
     */
98
    public function setDescription($description)
99
    {
100
        $this->description = $description;
101
102
        return $this;
103
    }
104
}
105