Passed
Push — master ( 40b19d...c1218d )
by Gabriel
12:51 queued 06:46
created

getShipperReleaseIndicator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Ups\Entity;
4
5
use DOMDocument;
6
use DOMElement;
7
use Ups\NodeInterface;
8
9
/**
10
 * Class PackageServiceOptions
11
 * @package Ups\Entity
12
 */
13
class PackageServiceOptions implements NodeInterface
14
{
15
    /**
16
     * @var COD
17
     */
18
    private $cod;
19
20
    /**
21
     * @var InsuredValue
22
     */
23
    private $insuredValue;
24
25
    /**
26
     * @var string
27
     */
28
    private $earliestDeliveryTime;
29
30
    /**
31
     * @var HazMat[]
32
     */
33
    private $hazMat = [];
34
35
    /**
36
     * @var HazMatPackageInformation
37
     */
38
    private $hazMatPackageInformation;
39
40
    /**
41
     * @var string
42
     */
43
    private $holdForPickup;
44
45
    /**
46
     * @var DeliveryConfirmation
47
     */
48
    private $deliveryConfirmation;
49
50
    /**
51
     * @var ShipperReleaseIndicator
52
     */
53
    private $ShipperReleaseIndicator;
54
55
    /**
56
     * @param null $parameters
57
     */
58 2
    public function __construct($parameters = null)
59
    {
60 2
        if (null !== $parameters) {
61
            if (isset($parameters->COD)) {
62
                $this->setCOD(new COD($parameters->COD));
63
            }
64
            if (isset($parameters->InsuredValue)) {
65
                $this->setInsuredValue(new InsuredValue($parameters->InsuredValue));
66
            }
67
            if (isset($parameters->EarliestDeliveryTime)) {
68
                $this->setEarliestDeliveryTime($parameters->EarliestDeliveryTime);
69
            }
70
            if (isset($parameters->HoldForPickup)) {
71
                $this->setHoldForPickup($parameters->HoldForPickup);
72
            }
73
            if (isset($parameters->DeliveryConfirmation)) {
74
                $this->setDeliveryConfirmation($parameters->DeliveryConfirmation);
75
            }
76
            if (isset($parameters->ShipperReleaseIndicator)) {
77
                $this->ShipperReleaseIndicator = $parameters->ShipperReleaseIndicator;
78
            }
79
        }
80 2
    }
81
82
    /**
83
     * @param null|DOMDocument $document
84
     *
85
     * @TODO: this seem to be awfully incomplete
86
     *
87
     * @return DOMElement
88
     */
89 2
    public function toNode(DOMDocument $document = null)
90
    {
91 2
        if (null === $document) {
92
            $document = new DOMDocument();
93
        }
94
95 2
        $node = $document->createElement('PackageServiceOptions');
96
97 2
        if ($this->getInsuredValue()) {
98
            $node->appendChild($this->getInsuredValue()->toNode($document));
99
        }
100 2
        foreach ($this->getHazMat() as $hazmat) {
101
            $node->appendChild($hazmat->toNode($document));
102 2
        }
103 2
        if ($this->getHazMatPackageInformation() !== null) {
104
            $node->appendChild($this->getHazMatPackageInformation()->toNode($document));
105
        }
106 2
        if (isset($this->deliveryConfirmation)) {
107
            $node->appendChild($this->deliveryConfirmation->toNode($document));
108
        }
109 2
        if (isset($this->ShipperReleaseIndicator)) {
110
            $node->appendChild($document->createElement('ShipperReleaseIndicator'));
111
        }
112
113 2
        return $node;
114
    }
115
116
    /**
117
     * @return InsuredValue|null
118
     */
119 2
    public function getInsuredValue()
120
    {
121 2
        return $this->insuredValue;
122
    }
123
124
    /**
125
     * @param $var
126
     */
127
    public function setInsuredValue($var)
128
    {
129
        $this->insuredValue = $var;
130
    }
131
132
    /**
133
     * @return COD|null
134
     */
135
    public function getCOD()
136
    {
137
        return $this->cod;
138
    }
139
140
    /**
141
     * @param $var
142
     */
143
    public function setCOD($var)
144
    {
145
        $this->cod = $var;
146
    }
147
148
    /**
149
     * @return string|null
150
     */
151
    public function getEarliestDeliveryTime()
152
    {
153
        return $this->earliestDeliveryTime;
154
    }
155
156
    /**
157
     * @param $var
158
     */
159
    public function setEarliestDeliveryTime($var)
160
    {
161
        $this->earliestDeliveryTime = $var;
162
    }
163
164
    /**
165
     * @return HazMat[]
166
     */
167 2
    public function getHazMat()
168
    {
169 2
        return $this->hazMat;
170
    }
171
172
    /**
173
     * @param HazMat[] $hazMat
174
     */
175
    public function setHazMat(array $hazMat)
176
    {
177
        $this->hazMat = $hazMat;
178
    }
179
180
    /**
181
     * @param HazMat $hazmat
182
     */
183
    public function addHazMat(HazMat $hazmat)
184
    {
185
        $this->hazMat[] = $hazmat;
186
    }
187
188
    /**
189
     * @return string|null
190
     */
191
    public function getHoldForPickup()
192
    {
193
        return $this->holdForPickup;
194
    }
195
196
    /**
197
     * @param $var
198
     */
199
    public function setHoldForPickup($var)
200
    {
201
        $this->holdForPickup = $var;
202
    }
203
204
    /**
205
     * @return HazMatPackageInformation
206
     */
207 2
    public function getHazMatPackageInformation()
208
    {
209 2
        return $this->hazMatPackageInformation;
210
    }
211
212
    /**
213
     * @param HazMatPackageInformation $hazMatPackageInformation
214
     */
215
    public function setHazMatPackageInformation($hazMatPackageInformation)
216
    {
217
        $this->hazMatPackageInformation = $hazMatPackageInformation;
218
    }
219
220
    /**
221
     * @param DeliveryConfirmation $deliveryConfirmation
222
     * @return ShipmentServiceOptions
223
     */
224
    public function setDeliveryConfirmation(DeliveryConfirmation $deliveryConfirmation)
225
    {
226
        $this->deliveryConfirmation = $deliveryConfirmation;
227
        return $this;
228
    }
229
230
    /**
231
     * @return DeliveryConfirmation|null
232
     */
233
    public function getDeliveryConfirmation()
234
    {
235
        return $this->deliveryConfirmation;
236
    }
237
238
    /**
239
     * @return mixed
240
     */
241
    public function getShipperReleaseIndicator()
242
    {
243
        return $this->ShipperReleaseIndicator;
244
    }
245
246
    /**
247
     * @param mixed $ShipperReleaseIndicator
248
     * @return ShipmentServiceOptions
249
     */
250
    public function setShipperReleaseIndicator($ShipperReleaseIndicator)
251
    {
252
        $this->ShipperReleaseIndicator = $ShipperReleaseIndicator;
253
        return $this;
254
    }
255
}
256