Completed
Pull Request — master (#134)
by
unknown
07:28
created

ShipmentServiceOptions::getSaturdayPickup()   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 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 1
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
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
    /**
18
     * @var bool
19
     */
20
    public $SaturdayPickup;
21
22
    /**
23
     * @var bool
24
     */
25
    public $SaturdayDelivery;
26
27
    /**
28
     * @var
29
     */
30
    public $COD;
31
32
    /**
33
     * @var CallTagARS
34
     */
35
    public $CallTagARS;
36
37
    /**
38
     * @var bool
39
     */
40
    public $NegotiatedRatesIndicator;
41
42
    /**
43
     * @var bool
44
     */
45
    public $DirectDeliveryOnlyIndicator;
46
47
    /**
48
     * @var
49
     */
50
    public $DeliverToAddresseeOnlyIndicator;
51
52
    /**
53
     * @var
54
     */
55
    private $internationalForms;
56
57
    /**
58
     * @var array
59
     */
60
    private $notifications = [];
61
62
    /**
63
     * @var AccessPointCOD
64
     */
65
    private $accessPointCOD;
66
        
67
    /**
68
     * @var bool
69
     */
70
    private $CarbonNeutral;
71
72
    /**
73
     * @param null $response
74
     */
75 6
    public function __construct($response = null)
76
    {
77 6
        $this->CallTagARS = new CallTagARS();
78
79 6
        if (null !== $response) {
80
            if (isset($response->SaturdayPickup)) {
81
                $this->SaturdayPickup = $response->SaturdayPickup;
82
            }
83
            if (isset($response->SaturdayDelivery)) {
84
                $this->SaturdayDelivery = $response->SaturdayDelivery;
85
            }
86
            if (isset($response->COD)) {
87
                $this->COD = $response->COD;
88
            }
89
            if (isset($response->AccessPointCOD)) {
90
                $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...
91
            }
92
            if (isset($response->CallTagARS)) {
93
                $this->CallTagARS = new CallTagARS($response->CallTagARS);
94
            }
95
            if (isset($response->NegotiatedRatesIndicator)) {
96
                $this->NegotiatedRatesIndicator = $response->NegotiatedRatesIndicator;
97
            }
98
            if (isset($response->DirectDeliveryOnlyIndicator)) {
99
                $this->DirectDeliveryOnlyIndicator = $response->DirectDeliveryOnlyIndicator;
100
            }            
101
            if (isset($response->CarbonNeutral)) {
102
                $this->CarbonNeutral = $response->CarbonNeutral;
103
            }
104
            if (isset($response->InternationalForms)) {
105
                $this->setInternationalForms($response->InternationalForms);
106
            }
107
        }
108 6
    }
109
110
    /**
111
     * @param null|DOMDocument $document
112
     *
113
     * @return DOMElement
114
     */
115 1
    public function toNode(DOMDocument $document = null)
116
    {
117 1
        if (null === $document) {
118
            $document = new DOMDocument();
119
        }
120
        
121 1
        $node = $document->createElement('ShipmentServiceOptions');
122
123 1
        if ($this->DirectDeliveryOnlyIndicator) {
124
            $node->appendChild($document->createElement('DirectDeliveryOnlyIndicator'));
125
        }
126
127 1
        if ($this->DeliverToAddresseeOnlyIndicator) {
128
            $node->appendChild($document->createElement('DeliverToAddresseeOnlyIndicator'));
129
        }
130
131 1
        if ($this->SaturdayPickup) {
132
            $node->appendChild($document->createElement('SaturdayPickup'));
133
        }
134
135 1
        if ($this->SaturdayDelivery) {
136
            $node->appendChild($document->createElement('SaturdayDelivery'));
137
        }
138
        
139 1
        if ($this->getCOD()) {
140
            $node->appendChild($this->getCOD()->toNode($document));
141
        }
142
143 1
        if ($this->getAccessPointCOD()) {
144
            $node->appendChild($this->getAccessPointCOD()->toNode($document));
145
        }
146
147 1
        if ($this->internationalForms) {
148
            $node->appendChild($this->internationalForms->toNode($document));
149
        }
150
151 1
        if (!empty($this->notifications)) {
152
            foreach ($this->notifications as $notification) {
153
                $node->appendChild($notification->toNode($document));
154
            }
155
        }
156
        
157 1
        return $node;
158
    }
159
160
    /**
161
     * @return AccessPointCOD
162
     */
163 1
    public function getAccessPointCOD()
164
    {
165 1
        return $this->accessPointCOD;
166
    }
167
168
    /**
169
     * @param $accessPointCOD
170
     * @return $this
171
     */
172
    public function setAccessPointCOD($accessPointCOD)
173
    {
174
        $this->accessPointCOD = $accessPointCOD;
175
        return $this;
176
    }
177
178
    /**
179
     * @param InternationalForms $data
180
     * @return $this
181
     */
182
    public function setInternationalForms(InternationalForms $data)
183
    {
184
        $this->internationalForms = $data;
185
        return $this;
186
    }
187
188
    /**
189
     * @return mixed
190
     */
191
    public function getInternationalForms()
192
    {
193
        return $this->internationalForms;
194
    }
195
196
    /**
197
     * @param Notification $notification
198
     *
199
     * @throws \Exception
200
     *
201
     * @return $this
202
     */
203
    public function addNotification(Notification $notification)
204
    {
205
        $this->notifications[] = $notification;
206
207
        if (count($this->notifications) > 3) {
208
            throw new \Exception('Maximum 3 notifications allowed');
209
        }
210
211
        return $this;
212
    }
213
214
    /**
215
     * @return array
216
     */
217
    public function getNotifications()
218
    {
219
        return $this->notifications;
220
    }
221
222
    /**
223
     * @return mixed
224
     */
225
    public function getSaturdayPickup()
226
    {
227
        return $this->SaturdayPickup;
228
    }
229
230
    /**
231
     * @param mixed $SaturdayPickup
232
     * @return ShipmentServiceOptions
233
     */
234
    public function setSaturdayPickup($SaturdayPickup)
235
    {
236
        $this->SaturdayPickup = $SaturdayPickup;
237
        return $this;
238
    }
239
240
    /**
241
     * @return mixed
242
     */
243
    public function getSaturdayDelivery()
244
    {
245
        return $this->SaturdayDelivery;
246
    }
247
248
    /**
249
     * @param mixed $SaturdayDelivery
250
     * @return ShipmentServiceOptions
251
     */
252
    public function setSaturdayDelivery($SaturdayDelivery)
253
    {
254
        $this->SaturdayDelivery = $SaturdayDelivery;
255
        return $this;
256
    }
257
258
    /**
259
     * @return mixed
260
     */
261 1
    public function getCOD()
262
    {
263 1
        return $this->COD;
264
    }
265
266
    /**
267
     * @param mixed $COD
268
     * @return ShipmentServiceOptions
269
     */
270
    public function setCOD($COD)
271
    {
272
        $this->COD = $COD;
273
        return $this;
274
    }
275
276
    /**
277
     * @return CallTagARS
278
     */
279
    public function getCallTagARS()
280
    {
281
        return $this->CallTagARS;
282
    }
283
284
    /**
285
     * @param CallTagARS $CallTagARS
286
     * @return ShipmentServiceOptions
287
     */
288
    public function setCallTagARS($CallTagARS)
289
    {
290
        $this->CallTagARS = $CallTagARS;
291
        return $this;
292
    }
293
294
    /**
295
     * @return bool
296
     */
297
    public function isNegotiatedRatesIndicator()
298
    {
299
        return $this->NegotiatedRatesIndicator;
300
    }
301
302
    /**
303
     * @param bool $NegotiatedRatesIndicator
304
     * @return ShipmentServiceOptions
305
     */
306
    public function setNegotiatedRatesIndicator($NegotiatedRatesIndicator)
307
    {
308
        $this->NegotiatedRatesIndicator = $NegotiatedRatesIndicator;
309
        return $this;
310
    }
311
312
    /**
313
     * @return bool
314
     */
315
    public function isDirectDeliveryOnlyIndicator()
316
    {
317
        return $this->DirectDeliveryOnlyIndicator;
318
    }
319
320
    /**
321
     * @param bool $DirectDeliveryOnlyIndicator
322
     * @return ShipmentServiceOptions
323
     */
324
    public function setDirectDeliveryOnlyIndicator($DirectDeliveryOnlyIndicator)
325
    {
326
        $this->DirectDeliveryOnlyIndicator = $DirectDeliveryOnlyIndicator;
327
        return $this;
328
    }
329
330
    /**
331
     * @return mixed
332
     */
333
    public function getDeliverToAddresseeOnlyIndicator()
334
    {
335
        return $this->DeliverToAddresseeOnlyIndicator;
336
    }
337
338
    /**
339
     * @param mixed $DeliverToAddresseeOnlyIndicator
340
     * @return ShipmentServiceOptions
341
     */
342
    public function setDeliverToAddresseeOnlyIndicator($DeliverToAddresseeOnlyIndicator)
343
    {
344
        $this->DeliverToAddresseeOnlyIndicator = $DeliverToAddresseeOnlyIndicator;
345
        return $this;
346
    }
347
    
348
    /**
349
     * @return bool
350
     */    
351
    public function getCarbonNeutral()
352
    {
353
        return $this->CarbonNeutral;
354
    }
355
356
    /**
357
     * @param bool $CarbonNeutral
358
     * @return ShipmentServiceOptions
359
     */
360
    public function setCarbonNeutral($CarbonNeutral)
361
    {
362
        $this->CarbonNeutral = $CarbonNeutral;
363
        return $this;
364
    }
365
    
366
}
367