Passed
Pull Request — master (#323)
by Сергей
02:41
created

AccessPointCOD   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 84
Duplicated Lines 28.57 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 0
dl 24
loc 84
ccs 0
cts 24
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 6 1
A getMonetaryValue() 0 4 1
A setMonetaryValue() 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
/**
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 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
     * @return DOMElement
44
     */
45 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...
46
    {
47
        if (null === $document) {
48
            $document = new DOMDocument();
49
        }
50
51
        $node = $document->createElement('AccessPointCOD');
52
53
        $node->appendChild($document->createElement('CurrencyCode', $this->getCurrencyCode()));
54
        $node->appendChild($document->createElement('MonetaryValue', $this->getMonetaryValue()));
55
56
        return $node;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getCurrencyCode()
63
    {
64
        return $this->currencyCode;
65
    }
66
67
    /**
68
     * @param string $currencyCode
69
     * @return AccessPointCOD
70
     */
71
    public function setCurrencyCode($currencyCode)
72
    {
73
        $this->currencyCode = $currencyCode;
74
75
        return $this;
76
    }
77
78
    /**
79
     * @return float
80
     */
81
    public function getMonetaryValue()
82
    {
83
        return $this->monetaryValue;
84
    }
85
86
    /**
87
     * @param float $monetaryValue
88
     * @return AccessPointCOD
89
     */
90
    public function setMonetaryValue($monetaryValue)
91
    {
92
        $this->monetaryValue = $monetaryValue;
93
94
        return $this;
95
    }
96
}
97