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

AccessPointCOD::__construct()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 0
cts 5
cp 0
rs 9.9
c 0
b 0
f 0
cc 4
nc 5
nop 1
crap 20
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