Completed
Push — master ( 035c71...ee69b0 )
by Stefan
09:37
created

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