Passed
Pull Request — master (#151)
by
unknown
05:33 queued 02:22
created

ItemizedPaymentInformation::getDutyAndTax()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
7
class ItemizedPaymentInformation
8
{
9
10
    /**
11
     * @var ShipmentCharge
12
     */
13
    private $transporation;
0 ignored issues
show
Unused Code introduced by
The property $transporation is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
15
    /**
16
     * @var ShipmentCharge
17
     */
18
    private $dutyAndTax;
19
20
    /**
21
     * @var bool
22
     */
23
    private $splitDutyVATIndicator;
24
25
    public function __construct($attributes = null)
26
    {
27
        if (isset($attributes->ShipmentCharges)) {
28
            foreach ($attributes->ShipmentCharges as $shipmentCharge) {
29
                if (!isset($shipmentCharge->Type)) {
30
                    continue;
31
                }
32
33
                if ($shipmentCharge->Type === ShipmentCharge::TYPE_TRANSPORTATION) {
34
                    $this->setTransportation(new ShipmentCharge($shipmentCharge));
35
                } elseif ($shipmentCharge->Type === ShipmentCharge::TYPE_DUTY_AND_TAX) {
36
                    $this->setDutyAndTax(new ShipmentCharge($shipmentCharge));
37
                }
38
            }
39
        }
40
41
        if (isset($attributes->SplitDutyVATIndicator)) {
42
            $this->setSplitDutyVATIndicator($attributes->SplitDutyVATIndicator);
0 ignored issues
show
Bug introduced by
The method setSplitDutyVATIndicator() does not exist on Ups\Entity\ItemizedPaymentInformation. Did you maybe mean setSplityDutyVATIndicator()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
43
        }
44
    }
45
46
    /**
47
     * @param null|DOMDocument $document
48
     *
49
     * @return DOMElement
50
     */
51
    public function toNode(DOMDocument $document = null)
52
    {
53
        if (is_null($document)) {
54
            $document = new DOMDocument();
55
        }
56
57
        $node = $document->createElement('ItemizedPaymentInformation');
58
        if ($this->getTransportation()) {
59
            $node->appendChild($this->getTransportation()->toNode($document));
60
        }
61
        if ($this->getDutyAndTax()) {
62
            $node->appendChild($this->getDutyAndTax()->toNode($document));
63
        }
64
        if ($this->getSplitDutyVATIndicator()) {
65
            $node->appendChild($document->createElement('SplitDutyVATIndicator'));
66
        }
67
68
        return $node;
69
    }
70
71
    /**
72
     * @return ShipmentCharge
73
     */
74
    public function getTransportation()
75
    {
76
        return $this->transportation;
0 ignored issues
show
Bug introduced by
The property transportation does not seem to exist. Did you mean transporation?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
77
    }
78
79
    /**
80
     * @param ShipmentCharge $transportation
81
     *
82
     * @return ItemizedPaymentInformation
83
     */
84
    public function setTransportation(ShipmentCharge $transportation)
85
    {
86
        $this->transportation = $transportation;
0 ignored issues
show
Bug introduced by
The property transportation does not seem to exist. Did you mean transporation?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
87
88
        return $this;
89
    }
90
91
    /**
92
     * @return ShipmentCharge
93
     */
94
    public function getDutyAndTax()
95
    {
96
        return $this->dutyAndTax;
97
    }
98
99
    /**
100
     * @param ShipmentCharge $dutyAndTax
101
     *
102
     * @return ItemizedPaymentInformation
103
     */
104
    public function setDutyAndTax(ShipmentCharge $dutyAndTax)
105
    {
106
        $this->dutyAndTax = $dutyAndTax;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return bool
113
     */
114
    public function getSplitDutyVATIndicator()
115
    {
116
        return $this->splitDutyVATIndicator;
117
    }
118
119
    /**
120
     * @param bool $splitDutyVATIndicator
121
     *
122
     * @return ItemizedPaymentInformation
123
     */
124
    public function setSplityDutyVATIndicator($splitDutyVATIndicator)
125
    {
126
        $this->splitDutyVATIndicator = $splitDutyVATIndicator;
127
128
        return $this;
129
    }
130
}
131