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

POA   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 96
Duplicated Lines 32.29 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 0
dl 31
loc 96
ccs 0
cts 28
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 4
A toNode() 20 20 4
A getCode() 0 4 1
A setCode() 0 6 1
A getDescription() 0 4 1
A setDescription() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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