Passed
Push — master ( 294393...d99a5b )
by Dieter
49s
created

UpdateRefund   C

Complexity

Total Complexity 30

Size/Duplication

Total Lines 295
Duplicated Lines 0 %

Coupling/Cohesion

Components 11
Dependencies 19

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 30
lcom 11
cbo 19
dl 0
loc 295
ccs 105
cts 105
cp 1
rs 6.25
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 47 6
A loadDateTimeInfo() 0 16 3
A loadReferences() 0 6 2
A loadTickets() 0 6 2
A loadPassengerPriority() 0 15 2
A loadMonetaryInfo() 0 10 3
A loadCommissions() 0 6 2
A loadFreeText() 0 6 2
A loadFop() 0 6 2
A loadRefundedItinerary() 0 6 2
A loadRefundedRoute() 0 6 2
A loadAddress() 0 6 2
1
<?php
2
/**
3
 * amadeus-ws-client
4
 *
5
 * Copyright 2015 Amadeus Benelux NV
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 * http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 *
19
 * @package Amadeus
20
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
21
 */
22
23
namespace Amadeus\Client\Struct\DocRefund;
24
25
use Amadeus\Client\RequestOptions\DocRefund\AddressOpt;
26
use Amadeus\Client\RequestOptions\DocRefund\CommissionOpt;
27
use Amadeus\Client\RequestOptions\DocRefund\FopOpt;
28
use Amadeus\Client\RequestOptions\DocRefund\FreeTextOpt;
29
use Amadeus\Client\RequestOptions\DocRefund\MonetaryData;
30
use Amadeus\Client\RequestOptions\DocRefund\Reference;
31
use Amadeus\Client\RequestOptions\DocRefund\RefundItinOpt;
32
use Amadeus\Client\RequestOptions\DocRefund\TaxData;
33
use Amadeus\Client\RequestOptions\DocRefund\Ticket as TicketOpt;
34
use Amadeus\Client\RequestOptions\DocRefundUpdateRefundOptions;
35
use Amadeus\Client\Struct\BaseWsMessage;
36
use Amadeus\Client\Struct\DocRefund\UpdateRefund\Commission;
37
use Amadeus\Client\Struct\DocRefund\UpdateRefund\DateTimeInformation;
38
use Amadeus\Client\Struct\DocRefund\UpdateRefund\FopGroup;
39
use Amadeus\Client\Struct\DocRefund\UpdateRefund\InteractiveFreeText;
40
use Amadeus\Client\Struct\DocRefund\UpdateRefund\MonetaryInformation;
41
use Amadeus\Client\Struct\DocRefund\UpdateRefund\PricingDetails;
42
use Amadeus\Client\Struct\DocRefund\UpdateRefund\ReferenceInformation;
43
use Amadeus\Client\Struct\DocRefund\UpdateRefund\RefundedItinerary;
44
use Amadeus\Client\Struct\DocRefund\UpdateRefund\RefundedRoute;
45
use Amadeus\Client\Struct\DocRefund\UpdateRefund\StructuredAddress;
46
use Amadeus\Client\Struct\DocRefund\UpdateRefund\TaxDetailsInformation;
47
use Amadeus\Client\Struct\DocRefund\UpdateRefund\Ticket;
48
use Amadeus\Client\Struct\DocRefund\UpdateRefund\TicketNumber;
49
use Amadeus\Client\Struct\DocRefund\UpdateRefund\TourInformation;
50
use Amadeus\Client\Struct\DocRefund\UpdateRefund\TravellerInformation;
51
use Amadeus\Client\Struct\DocRefund\UpdateRefund\TravellerPriorityInfo;
52
use Amadeus\Client\Struct\DocRefund\UpdateRefund\UserIdentification;
53
54
/**
55
 * DocRefund_UpdateRefund request structure
56
 *
57
 * @package Amadeus\Client\Struct\DocRefund
58
 * @author Dieter Devlieghere <[email protected]>
59
 */
60
class UpdateRefund extends BaseWsMessage
61
{
62
    /**
63
     * @var UpdateRefund\UserIdentification
64
     */
65
    public $userIdentification;
66
67
    /**
68
     * @var UpdateRefund\TicketNumber
69
     */
70
    public $ticketNumber;
71
72
    /**
73
     * @var UpdateRefund\DateTimeInformation[]
74
     */
75
    public $dateTimeInformation = [];
76
77
    /**
78
     * @var UpdateRefund\ReferenceInformation
79
     */
80
    public $referenceInformation;
81
82
    /**
83
     * @var UpdateRefund\TravellerInformation
84
     */
85
    public $travellerInformation;
86
87
    /**
88
     * @var UpdateRefund\Ticket[]
89
     */
90
    public $ticket = [];
91
92
    /**
93
     * @var UpdateRefund\TravellerPriorityInfo
94
     */
95
    public $travellerPriorityInfo;
96
97
    /**
98
     * @var UpdateRefund\MonetaryInformation
99
     */
100
    public $monetaryInformation;
101
102
    /**
103
     * @var UpdateRefund\PricingDetails
104
     */
105
    public $pricingDetails;
106
107
    /**
108
     * @var UpdateRefund\Commission
109
     */
110
    public $commission;
111
112
    /**
113
     * @var UpdateRefund\TaxDetailsInformation[]
114
     */
115
    public $taxDetailsInformation = [];
116
117
    /**
118
     * @var UpdateRefund\TourInformation
119
     */
120
    public $tourInformation;
121
122
    /**
123
     * @var UpdateRefund\InteractiveFreeText[]
124
     */
125
    public $interactiveFreeText = [];
126
127
    /**
128
     * @var UpdateRefund\FopGroup[]
129
     */
130
    public $fopGroup = [];
131
132
    /**
133
     * @var UpdateRefund\TransactionContext
134
     */
135
    public $transactionContext;
136
137
    /**
138
     * @var UpdateRefund\FirstAndLastSegmentDates
139
     */
140
    public $firstAndLastSegmentDates;
141
142
    /**
143
     * @var UpdateRefund\OriginAndDestination
144
     */
145
    public $originAndDestination;
146
147
    /**
148
     * @var UpdateRefund\RefundedItinerary[]
149
     */
150
    public $refundedItinerary = [];
151
152
    /**
153
     * @var UpdateRefund\RefundedRoute
154
     */
155
    public $refundedRoute;
156
157
    /**
158
     * @var UpdateRefund\StructuredAddress
159
     */
160
    public $structuredAddress;
161
162
    /**
163
     * @var UpdateRefund\FeeGroup
164
     */
165
    public $feeGroup;
166
167
    /**
168
     * UpdateRefund constructor.
169
     *
170
     * @param DocRefundUpdateRefundOptions $options
171
     */
172 6
    public function __construct(DocRefundUpdateRefundOptions $options)
173
    {
174 6
        if ($this->checkAnyNotEmpty($options->originator, $options->originatorId)) {
175 4
            $this->userIdentification = new UserIdentification(
176 4
                $options->originatorId,
177 4
                $options->originator
178 4
            );
179 4
        }
180
181 6
        if ($this->checkAnyNotEmpty($options->ticketNumber, $options->ticketType)) {
182 1
            $this->ticketNumber = new TicketNumber($options->ticketNumber, $options->ticketType);
183 1
        }
184
185 6
        $this->loadDateTimeInfo($options->refundDate, $options->ticketedDate);
186
187 6
        $this->loadReferences($options->references);
188
189 6
        if (!empty($options->passengerSurName)) {
190 2
            $this->travellerInformation = new TravellerInformation($options->passengerSurName);
191 2
        }
192
193 6
        $this->loadTickets($options->tickets);
194
195 6
        $this->loadPassengerPriority($options);
196
197 6
        $this->loadMonetaryInfo($options->monetaryData, $options->taxData);
198
199 6
        if (!empty($options->pricingTicketIndicator)) {
200 1
            $this->pricingDetails = new PricingDetails($options->pricingTicketIndicator);
201 1
        }
202
203 6
        $this->loadCommissions($options->commission);
204
205 6
        if (!empty($options->tourCode)) {
206 1
            $this->tourInformation = new TourInformation($options->tourCode);
207 1
        }
208
209 6
        $this->loadFreeText($options->freeText);
210
211 6
        $this->loadFop($options->formOfPayment);
212
213 6
        $this->loadRefundedItinerary($options->refundedItinerary);
214
215 6
        $this->loadRefundedRoute($options->refundedRouteStations);
216
217 6
        $this->loadAddress($options->address);
218 6
    }
219
220
    /**
221
     * @param \DateTime|null $refundDate
222
     * @param \DateTime|null $ticketedDate
223
     */
224 6
    protected function loadDateTimeInfo($refundDate, $ticketedDate)
225
    {
226 6
        if ($refundDate instanceof \DateTime) {
227 4
            $this->dateTimeInformation[] = new DateTimeInformation(
228 4
                DateTimeInformation::OPT_DATE_OF_REFUND,
229
                $refundDate
230 4
            );
231 4
        }
232
233 6
        if ($ticketedDate instanceof \DateTime) {
234 4
            $this->dateTimeInformation[] = new DateTimeInformation(
235 4
                DateTimeInformation::OPT_DATE_TICKETED,
236
                $ticketedDate
237 4
            );
238 4
        }
239 6
    }
240
241
    /**
242
     * @param Reference[] $references
243
     */
244 6
    protected function loadReferences($references)
245
    {
246 6
        if (!empty($references)) {
247 5
            $this->referenceInformation = new ReferenceInformation($references);
248 5
        }
249 6
    }
250
251
    /**
252
     * @param TicketOpt[] $tickets
253
     */
254 6
    protected function loadTickets($tickets)
255
    {
256 6
        foreach ($tickets as $ticket) {
257 4
            $this->ticket[] = new Ticket($ticket);
258 6
        }
259 6
    }
260
261
    /**
262
     * @param DocRefundUpdateRefundOptions $options
263
     */
264 6
    protected function loadPassengerPriority($options)
265
    {
266 6
        if ($this->checkAnyNotEmpty(
267 6
            $options->travellerPrioCompany,
268 6
            $options->travellerPrioDateOfJoining,
269 6
            $options->travellerPrioReference
270 6
        )
271 6
        ) {
272 3
            $this->travellerPriorityInfo = new TravellerPriorityInfo(
273 3
                $options->travellerPrioCompany,
274 3
                $options->travellerPrioDateOfJoining,
275 3
                $options->travellerPrioReference
276 3
            );
277 3
        }
278 6
    }
279
280
    /**
281
     * @param MonetaryData[] $monetaryData
282
     * @param TaxData[] $taxData
283
     */
284 6
    protected function loadMonetaryInfo($monetaryData, $taxData)
285
    {
286 6
        if (!empty($monetaryData)) {
287 4
            $this->monetaryInformation = new MonetaryInformation($monetaryData);
288 4
        }
289
290 6
        foreach ($taxData as $tax) {
291 4
            $this->taxDetailsInformation[] = new TaxDetailsInformation($tax);
292 6
        }
293 6
    }
294
295
    /**
296
     * @param CommissionOpt[] $commission
297
     */
298 6
    protected function loadCommissions($commission)
299
    {
300 6
        if (!empty($commission)) {
301 1
            $this->commission = new Commission($commission);
302 1
        }
303 6
    }
304
305
    /**
306
     * @param FreeTextOpt[] $freeText
307
     */
308 6
    protected function loadFreeText($freeText)
309
    {
310 6
        foreach ($freeText as $opt) {
311 1
            $this->interactiveFreeText[] = new InteractiveFreeText($opt);
312 6
        }
313 6
    }
314
315
    /**
316
     * @param FopOpt[] $formOfPayment
317
     */
318 6
    protected function loadFop($formOfPayment)
319
    {
320 6
        foreach ($formOfPayment as $fop) {
321 4
            $this->fopGroup[] = new FopGroup($fop);
322 6
        }
323 6
    }
324
325
    /**
326
     * @param RefundItinOpt[] $refundedItinerary
327
     */
328 6
    protected function loadRefundedItinerary($refundedItinerary)
329
    {
330 6
        foreach ($refundedItinerary as $itin) {
331 1
            $this->refundedItinerary[] = new RefundedItinerary($itin);
332 6
        }
333 6
    }
334
335
    /**
336
     * @param string[] $refundedRouteStations
337
     */
338 6
    protected function loadRefundedRoute($refundedRouteStations)
339
    {
340 6
        if (!empty($refundedRouteStations)) {
341 3
            $this->refundedRoute = new RefundedRoute($refundedRouteStations);
342 3
        }
343 6
    }
344
345
    /**
346
     * @param AddressOpt|null $address
347
     */
348 6
    protected function loadAddress($address)
349
    {
350 6
        if ($address instanceof AddressOpt) {
351 1
            $this->structuredAddress = new StructuredAddress($address);
352 1
        }
353 6
    }
354
}
355