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

Quantity::setUnitOfMeasurement()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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