Code Duplication    Length = 63-63 lines in 2 locations

src/Entity/InvoiceLineTotal.php 1 location

@@ 9-71 (lines=63) @@
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class InvoiceLineTotal implements NodeInterface
10
{
11
    private $currencyCode;
12
    private $monetaryValue;
13
14
    public function __construct($response = null)
15
    {
16
        if (null !== $response) {
17
            if (isset($response->CurrencyCode)) {
18
                $this->setCurrencyCode($response->CurrencyCode);
19
            }
20
            if (isset($response->MonetaryValue)) {
21
                $this->setMonetaryValue($response->MonetaryValue);
22
            }
23
        }
24
    }
25
26
    /**
27
     * @param null|DOMDocument $document
28
     *
29
     * @return DOMElement
30
     */
31
    public function toNode(DOMDocument $document = null)
32
    {
33
        if (null === $document) {
34
            $document = new DOMDocument();
35
        }
36
37
        $node = $document->createElement('InvoiceLineTotal');
38
39
        if ($this->getCurrencyCode()) {
40
            $node->appendChild($document->createElement('CurrencyCode', $this->getCurrencyCode()));
41
        }
42
43
        $node->appendChild($document->createElement('MonetaryValue', $this->getMonetaryValue()));
44
45
        return $node;
46
    }
47
48
    public function getCurrencyCode()
49
    {
50
        return $this->currencyCode;
51
    }
52
53
    public function setCurrencyCode($var)
54
    {
55
        $this->currencyCode = $var;
56
    }
57
58
    public function getMonetaryValue()
59
    {
60
        return $this->monetaryValue;
61
    }
62
63
    public function setMonetaryValue($var)
64
    {
65
        if (!is_numeric($var)) {
66
            throw new \Exception('Monetary value should be a numeric value');
67
        }
68
69
        $this->monetaryValue = $var;
70
    }
71
}
72

src/Entity/ShipmentTotalWeight.php 1 location

@@ 9-71 (lines=63) @@
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
class ShipmentTotalWeight implements NodeInterface
10
{
11
    private $UnitOfMeasurement;
12
    private $Weight;
13
14
    public function __construct($response = null)
15
    {
16
        if (null !== $response) {
17
            if (isset($response->UnitOfMeasurement)) {
18
                $this->setUnitOfMeasurement($response->UnitOfMeasurement);
19
            }
20
            if (isset($response->Weight)) {
21
                $this->setWeight($response->Weight);
22
            }
23
        }
24
    }
25
26
    /**
27
     * @param null|DOMDocument $document
28
     *
29
     * @return DOMElement
30
     */
31
    public function toNode(DOMDocument $document = null)
32
    {
33
        if (null === $document) {
34
            $document = new DOMDocument();
35
        }
36
37
        $node = $document->createElement('ShipmentTotalWeight');
38
        if ($this->getUnitOfMeasurement()) {
39
            $node->appendChild($this->getUnitOfMeasurement()->toNode($document));
40
        }
41
42
        $node->appendChild($document->createElement('Weight', $this->getWeight()));
43
        
44
        return $node;
45
    }
46
47
    public function getUnitOfMeasurement()
48
    {
49
        return $this->UnitOfMeasurement;
50
    }
51
52
    public function setUnitOfMeasurement($var)
53
    {
54
        $this->UnitOfMeasurement = $var;
55
    }
56
57
    public function getWeight()
58
    {
59
        return $this->Weight;
60
    }
61
62
    public function setWeight($var)
63
    {
64
        if (!is_numeric($var)) {
65
            throw new \Exception('Weight value should be a numeric value');
66
        }
67
68
        $this->Weight = $var;
69
    }
70
}
71