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

UnitPrice::toNode()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 3.576

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 6
cts 10
cp 0.6
rs 9.6666
c 0
b 0
f 0
cc 3
nc 4
nop 1
crap 3.576
1
<?php
2
3
namespace Ups\Entity\Tradeability;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
/**
10
 * Class UnitPrice.
11
 */
12
class UnitPrice implements NodeInterface
13
{
14
15
    /**
16
     * @var float
17
     */
18
    private $monetaryValue;
19
20
    /**
21
     * @var string
22
     */
23
    private $currencyCode;
24
25
    /**
26
     * @param null|DOMDocument $document
27
     *
28
     * @return DOMElement
29
     */
30 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...
31
    {
32 1
        if (null === $document) {
33
            $document = new DOMDocument();
34
        }
35
36 1
        $node = $document->createElement('UnitPrice');
37
38
        // Required
39 1
        $node->appendChild($document->createElement('MonetaryValue', $this->getMonetaryValue()));
40
41
        // Optional
42 1
        if ($this->getCurrencyCode() !== null) {
43
            $node->appendChild($document->createElement('CurrencyCode', $this->getCurrencyCode()));
44
        }
45
46 1
        return $node;
47
    }
48
49
    /**
50
     * @return float
51
     */
52 1
    public function getMonetaryValue()
53
    {
54 1
        return $this->monetaryValue;
55
    }
56
57
    /**
58
     * @param float $monetaryValue
59
     * @return UnitPrice
60
     */
61
    public function setMonetaryValue($monetaryValue)
62
    {
63
        $this->monetaryValue = $monetaryValue;
64
65
        return $this;
66
    }
67
68
    /**
69
     * @return string
70
     */
71 1
    public function getCurrencyCode()
72
    {
73 1
        return $this->currencyCode;
74
    }
75
76
    /**
77
     * @param string $currencyCode
78
     * @return UnitPrice
79
     */
80
    public function setCurrencyCode($currencyCode)
81
    {
82
        $this->currencyCode = $currencyCode;
83
84
        return $this;
85
    }
86
}
87