Passed
Push — master ( ddb3c8...d3e504 )
by Pierre
02:25
created

AccessPointCOD   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 79
Duplicated Lines 30.38 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 24
loc 79
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 4
A toNode() 13 13 2
A getCurrencyCode() 0 4 1
A setCurrencyCode() 0 4 1
A getMonetaryValue() 0 4 1
A setMonetaryValue() 0 4 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
/**
10
 * Class AccessPointCOD
11
 * @package Ups\Entity
12
 */
13
class AccessPointCOD implements NodeInterface
14
{
15
16
    /**
17
     * @var string
18
     */
19
    private $currencyCode;
20
21
    /**
22
     * @var float
23
     */
24
    private $monetaryValue;
25
26
    /**
27
     * @param \stdClass|null $response
28
     */
29 View Code Duplication
    public function __construct(\stdClass $response = 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...
30
    {
31
        if (null !== $response) {
32
            if (isset($response->CurrencyCode)) {
33
                $this->setCurrencyCode($response->CurrencyCode);
34
            }
35
            if (isset($response->MonetaryValue)) {
36
                $this->setMonetaryValue($response->MonetaryValue);
37
            }
38
        }
39
    }
40
41
    /**
42
     * @param null|DOMDocument $document
43
     *
44
     * @return DOMElement
45
     */
46 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...
47
    {
48
        if (null === $document) {
49
            $document = new DOMDocument();
50
        }
51
52
        $node = $document->createElement('AccessPointCOD');
53
54
        $node->appendChild($document->createElement('CurrencyCode', $this->getCurrencyCode()));
55
        $node->appendChild($document->createElement('MonetaryValue', $this->getMonetaryValue()));
56
57
        return $node;
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getCurrencyCode()
64
    {
65
        return $this->currencyCode;
66
    }
67
68
    /**
69
     * @param string $currencyCode
70
     */
71
    public function setCurrencyCode($currencyCode)
72
    {
73
        $this->currencyCode = $currencyCode;
74
    }
75
76
    /**
77
     * @return float
78
     */
79
    public function getMonetaryValue()
80
    {
81
        return $this->monetaryValue;
82
    }
83
84
    /**
85
     * @param float $monetaryValue
86
     */
87
    public function setMonetaryValue($monetaryValue)
88
    {
89
        $this->monetaryValue = $monetaryValue;
90
    }
91
}
92