Completed
Push — master ( 688cd0...364e9f )
by Stefan
02:52
created

ShipmentServiceOptions::getLabelMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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