Completed
Pull Request — master (#189)
by
unknown
02:36
created

ShipmentServiceOptions::getDeliveryConfirmation()   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
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
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 ShipmentServiceOptions
11
 * @package Ups\Entity
12
 */
13
// @todo Refactor to private properties
14
class ShipmentServiceOptions implements NodeInterface
15
{
16
    /**
17
     * @var
18
     */
19
    public $SaturdayPickup;
20
21
    /**
22
     * @var
23
     */
24
    public $SaturdayDelivery;
25
26
    /**
27
     * @var
28
     */
29
    public $COD;
30
31
    /**
32
     * @var CallTagARS
33
     */
34
    public $CallTagARS;
35
36
    /**
37
     * @var
38
     */
39
    public $NegotiatedRatesIndicator;
40
41
    /**
42
     * @var
43
     */
44
    public $DirectDeliveryOnlyIndicator;
45
46
    /**
47
     * @var
48
     */
49
    public $DeliverToAddresseeOnlyIndicator;
50
51
    /**
52
     * @var
53
     */
54
    private $internationalForms;
55
56
    /**
57
     * @var null|LabelMethod
58
     */
59
    private $labelMethod;
60
61
    /**
62
     * @var array
63
     */
64
    private $notifications = [];
65
66
    /**
67
     * @var AccessPointCOD
68
     */
69
    private $accessPointCOD;
70
71
    /**
72
     * @var boolean
73
     */
74
    private $importControlIndicator;
75
76
    /**
77
     * @var null|DeliveryConfirmation
78
     */
79
    private $deliveryConfirmation;
80
81
    /**
82
     * @param null $response
83
     */
84 9
    public function __construct($response = null)
85
    {
86 9
        $this->CallTagARS = new CallTagARS();
87
88 9
        if (null !== $response) {
89 2
            if (isset($response->SaturdayPickup)) {
90
                $this->SaturdayPickup = $response->SaturdayPickup;
91
            }
92 2
            if (isset($response->SaturdayDelivery)) {
93
                $this->SaturdayDelivery = $response->SaturdayDelivery;
94
            }
95 2
            if (isset($response->COD)) {
96
                $this->COD = $response->COD;
97
            }
98 2
            if (isset($response->AccessPointCOD)) {
99
                $this->setAccessPointCOD(new AccessPointCOD($response->AccessPointCOD));
0 ignored issues
show
Unused Code introduced by
The call to AccessPointCOD::__construct() has too many arguments starting with $response->AccessPointCOD.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
100
            }
101 2
            if (isset($response->CallTagARS)) {
102
                $this->CallTagARS = new CallTagARS($response->CallTagARS);
103
            }
104 2
            if (isset($response->NegotiatedRatesIndicator)) {
105
                $this->NegotiatedRatesIndicator = $response->NegotiatedRatesIndicator;
106
            }
107 2
            if (isset($response->DirectDeliveryOnlyIndicator)) {
108
                $this->DirectDeliveryOnlyIndicator = $response->DirectDeliveryOnlyIndicator;
109
            }
110 2
            if (isset($response->DeliverToAddresseeOnlyIndicator)) {
111
                $this->DeliverToAddresseeOnlyIndicator = $response->DeliverToAddresseeOnlyIndicator;
112
            }
113 2
            if (isset($response->InternationalForms)) {
114
                $this->setInternationalForms($response->InternationalForms);
115
            }
116 2
            if (isset($response->ImportControlIndicator)) {
117 2
                $this->setImportControlIndicator($response->ImportControlIndicator);
118 2
            }
119 2
            if (isset($response->DeliveryConfirmation)) {
120
                $this->setDeliveryConfirmation($response->DeliveryConfirmation);
121
            }
122 2
            if (isset($response->LabelMethod)) {
123 2
                $this->setLabelMethod(new LabelMethod($response->LabelMethod));
124 2
            }
125 2
        }
126 9
    }
127
128
    /**
129
     * @param null|DOMDocument $document
130
     *
131
     * @return DOMElement
132
     */
133 2
    public function toNode(DOMDocument $document = null)
134
    {
135 2
        if (null === $document) {
136
            $document = new DOMDocument();
137
        }
138
139 2
        $node = $document->createElement('ShipmentServiceOptions');
140
141 2
        if (isset($this->DirectDeliveryOnlyIndicator)) {
142
            $node->appendChild($document->createElement('DirectDeliveryOnlyIndicator'));
143
        }
144
145 2
        if (isset($this->DeliverToAddresseeOnlyIndicator)) {
146
            $node->appendChild($document->createElement('DeliverToAddresseeOnlyIndicator'));
147
        }
148
149 2
        if (isset($this->SaturdayPickup)) {
150
            $node->appendChild($document->createElement('SaturdayPickup'));
151
        }
152
153 2
        if (isset($this->SaturdayDelivery)) {
154
            $node->appendChild($document->createElement('SaturdayDelivery'));
155
        }
156
157 2
        if ($this->getCOD()) {
158
            $node->appendChild($this->getCOD()->toNode($document));
159
        }
160
161 2
        if ($this->getAccessPointCOD()) {
162
            $node->appendChild($this->getAccessPointCOD()->toNode($document));
163
        }
164
165 2
        if (isset($this->internationalForms)) {
166
            $node->appendChild($this->internationalForms->toNode($document));
167
        }
168
169 2
        if (isset($this->deliveryConfirmation)) {
170
            $node->appendChild($this->deliveryConfirmation->toNode($document));
171
        }
172
173 2
        if (isset($this->importControlIndicator)) {
174 1
            $node->appendChild($document->createElement('ImportControlIndicator'));
175 1
        }
176
177 2
        if (isset($this->labelMethod)) {
178 1
            $node->appendChild($this->labelMethod->toNode($document));
179 1
        }
180
181 2
        if (!empty($this->notifications)) {
182
            foreach ($this->notifications as $notification) {
183
                $node->appendChild($notification->toNode($document));
184
            }
185
        }
186
187 2
        return $node;
188
    }
189
190
    /**
191
     * @return AccessPointCOD
192
     */
193 2
    public function getAccessPointCOD()
194
    {
195 2
        return $this->accessPointCOD;
196
    }
197
198
    /**
199
     * @param $accessPointCOD
200
     * @return $this
201
     */
202
    public function setAccessPointCOD($accessPointCOD)
203
    {
204
        $this->accessPointCOD = $accessPointCOD;
205
        return $this;
206
    }
207
208
    /**
209
     * @param InternationalForms $data
210
     * @return $this
211
     */
212
    public function setInternationalForms(InternationalForms $data)
213
    {
214
        $this->internationalForms = $data;
215
        return $this;
216
    }
217
218
    /**
219
     * @return mixed
220
     */
221
    public function getInternationalForms()
222
    {
223
        return $this->internationalForms;
224
    }
225
226
    /**
227
     * @param LabelMethod $data
228
     * @return $this
229
     */
230 2
    public function setLabelMethod(LabelMethod $data)
231
    {
232 2
        $this->labelMethod = $data;
233 2
        return $this;
234
    }
235
236
    /**
237
     * @return null|LabelMethod
238
     *
239
     */
240 1
    public function getLabelMethod()
241
    {
242 1
        return $this->labelMethod;
243
    }
244
245
    /**
246
     * @param Notification $notification
247
     *
248
     * @throws \Exception
249
     *
250
     * @return $this
251
     */
252
    public function addNotification(Notification $notification)
253
    {
254
        $this->notifications[] = $notification;
255
256
        if (count($this->notifications) > 3) {
257
            throw new \Exception('Maximum 3 notifications allowed');
258
        }
259
260
        return $this;
261
    }
262
263
    /**
264
     * @return array
265
     */
266
    public function getNotifications()
267
    {
268
        return $this->notifications;
269
    }
270
271
    /**
272
     * @return mixed
273
     */
274
    public function getSaturdayPickup()
275
    {
276
        return $this->SaturdayPickup;
277
    }
278
279
    /**
280
     * @param mixed $SaturdayPickup
281
     * @return ShipmentServiceOptions
282
     */
283
    public function setSaturdayPickup($SaturdayPickup)
284
    {
285
        $this->SaturdayPickup = $SaturdayPickup;
286
        return $this;
287
    }
288
289
    /**
290
     * @return mixed
291
     */
292
    public function getSaturdayDelivery()
293
    {
294
        return $this->SaturdayDelivery;
295
    }
296
297
    /**
298
     * @param mixed $SaturdayDelivery
299
     * @return ShipmentServiceOptions
300
     */
301
    public function setSaturdayDelivery($SaturdayDelivery)
302
    {
303
        $this->SaturdayDelivery = $SaturdayDelivery;
304
        return $this;
305
    }
306
307
    /**
308
     * @return mixed
309
     */
310 2
    public function getCOD()
311
    {
312 2
        return $this->COD;
313
    }
314
315
    /**
316
     * @param mixed $COD
317
     * @return ShipmentServiceOptions
318
     */
319
    public function setCOD($COD)
320
    {
321
        $this->COD = $COD;
322
        return $this;
323
    }
324
325
326
    /**
327
     * @return CallTagARS
328
     */
329
    public function getCallTagARS()
330
    {
331
        return $this->CallTagARS;
332
    }
333
334
    /**
335
     * @param CallTagARS $CallTagARS
336
     * @return ShipmentServiceOptions
337
     */
338
    public function setCallTagARS($CallTagARS)
339
    {
340
        $this->CallTagARS = $CallTagARS;
341
        return $this;
342
    }
343
344
    /**
345
     * @return boolean
346
     */
347
    public function isNegotiatedRatesIndicator()
348
    {
349
        return $this->NegotiatedRatesIndicator;
350
    }
351
352
    /**
353
     * @param boolean $NegotiatedRatesIndicator
354
     * @return ShipmentServiceOptions
355
     */
356
    public function setNegotiatedRatesIndicator($NegotiatedRatesIndicator)
357
    {
358
        $this->NegotiatedRatesIndicator = $NegotiatedRatesIndicator;
359
        return $this;
360
    }
361
362
    /**
363
     * @return boolean
364
     */
365 2
    public function isImportControlIndicator()
366
    {
367 2
        return $this->importControlIndicator;
368
    }
369
370
    /**
371
     * @param boolean $importControlIndicator
372
     * @return ShipmentServiceOptions
373
     */
374 3
    public function setImportControlIndicator($importControlIndicator)
375
    {
376 3
        $this->importControlIndicator = $importControlIndicator;
377 3
        return $this;
378
    }
379
380
    /**
381
     * @param DeliveryConfirmation $deliveryConfirmation
382
     * @return ShipmentServiceOptions
383
     */
384
    public function setDeliveryConfirmation($deliveryConfirmation)
385
    {
386
        $this->deliveryConfirmation = $deliveryConfirmation;
387
        return $this;
388
    }
389
390
    /**
391
     * @return DeliveryConfirmation
392
     */
393
    public function getDeliveryConfirmation()
394
    {
395
        return $this->deliveryConfirmation;
396
    }
397
398
    /**
399
     * @return boolean
400
     */
401
    public function isDirectDeliveryOnlyIndicator()
402
    {
403
        return $this->DirectDeliveryOnlyIndicator;
404
    }
405
406
    /**
407
     * @param boolean $DirectDeliveryOnlyIndicator
408
     * @return ShipmentServiceOptions
409
     */
410
    public function setDirectDeliveryOnlyIndicator($DirectDeliveryOnlyIndicator)
411
    {
412
        $this->DirectDeliveryOnlyIndicator = $DirectDeliveryOnlyIndicator;
413
        return $this;
414
    }
415
416
    /**
417
     * @return mixed
418
     */
419
    public function getDeliverToAddresseeOnlyIndicator()
420
    {
421
        return $this->DeliverToAddresseeOnlyIndicator;
422
    }
423
424
    /**
425
     * @param mixed $DeliverToAddresseeOnlyIndicator
426
     * @return ShipmentServiceOptions
427
     */
428
    public function setDeliverToAddresseeOnlyIndicator($DeliverToAddresseeOnlyIndicator)
429
    {
430
        $this->DeliverToAddresseeOnlyIndicator = $DeliverToAddresseeOnlyIndicator;
431
        return $this;
432
    }
433
}
434