Passed
Pull Request — master (#223)
by
unknown
02:52
created

FreightCharges   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 49
Duplicated Lines 24.49 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 12
loc 49
ccs 12
cts 21
cp 0.5714
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A toNode() 12 12 2
A getCurrencyCode() 0 4 1
A setCurrencyCode() 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\Tradeability;
4
5
use DOMDocument;
6
use DOMElement;
7
8
class FreightCharges extends \Ups\Entity\FreightCharges
9
{
10
    private $currencyCode;
11
12 1
    public function __construct($response = null)
13
    {
14 1
        if (null !== $response) {
15
            if (isset($response->CurrencyCode)) {
16
                $this->setCurrencyCode($response->CurrencyCode);
17
            }
18
        }
19
20 1
        parent::__construct($response);
21 1
    }
22
23
    /**
24
     * @param null|DOMDocument $document
25
     *
26
     * @return DOMElement
27
     */
28 1 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...
29
    {
30 1
        if (null === $document) {
31
            $document = new DOMDocument();
32
        }
33
34 1
        $node = $document->createElement('FreightCharges');
35 1
        $node->appendChild($document->createElement('MonetaryValue', $this->getMonetaryValue()));
36 1
        $node->appendChild($document->createElement('CurrencyCode', $this->getCurrencyCode()));
37
38 1
        return $node;
39
    }
40
41
    /**
42
     * @return mixed
43
     */
44 1
    public function getCurrencyCode()
45
    {
46 1
        return $this->currencyCode;
47
    }
48
49
    /**
50
     * @param mixed $currencyCode
51
     */
52
    public function setCurrencyCode($currencyCode)
53
    {
54
        $this->currencyCode = $currencyCode;
55
    }
56
}
57