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\Fare; |
24
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestCreator\MessageVersionUnsupportedException; |
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\AwardPricing; |
27
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax; |
28
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis; |
29
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareFamily; |
30
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\FormOfPayment; |
31
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ObFee; |
32
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef; |
33
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax; |
34
|
|
|
use Amadeus\Client\RequestOptions\Fare\PricePnr\ZapOff; |
35
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions; |
36
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions as LowerFareOpt; |
37
|
|
|
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt; |
38
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions as InformativePriceOpt; |
39
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation; |
40
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\Currency; |
41
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation; |
42
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation; |
43
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation; |
44
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentTravellerDetails; |
45
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation; |
46
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail; |
47
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference; |
48
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PenDisInformation; |
49
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup; |
50
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionKey; |
51
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\TaxData; |
52
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\TaxInformation; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Fare_PricePNRWithBookingClass v 13 and higher structure |
56
|
|
|
* |
57
|
|
|
* @package Amadeus\Client\Struct\Fare |
58
|
|
|
* @author dieter <[email protected]> |
59
|
|
|
*/ |
60
|
|
|
class PricePNRWithBookingClass13 extends BasePricingMessage |
61
|
|
|
{ |
62
|
|
|
/** |
63
|
|
|
* @var PricePnr13\PricingOptionGroup[] |
64
|
|
|
*/ |
65
|
|
|
public $pricingOptionGroup = []; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* PricePNRWithBookingClass13 constructor. |
69
|
|
|
* |
70
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|InformativePriceOpt|null $options |
71
|
120 |
|
* @throws MessageVersionUnsupportedException |
72
|
|
|
*/ |
73
|
120 |
|
public function __construct($options) |
74
|
120 |
|
{ |
75
|
48 |
|
if (!is_null($options)) { |
76
|
120 |
|
$this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Load an array of PricingOptionGroup objects from the Pricing request options. |
82
|
|
|
* |
83
|
|
|
* Extracted because this method is also used in the InformativePricingWithoutPnr messages. |
84
|
|
|
* |
85
|
|
|
* @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|InformativePriceOpt $options |
86
|
155 |
|
* @return PricingOptionGroup[] |
87
|
|
|
*/ |
88
|
155 |
|
public static function loadPricingOptionsFromRequestOptions($options) |
89
|
|
|
{ |
90
|
155 |
|
$priceOptions = []; |
91
|
155 |
|
|
92
|
155 |
|
$priceOptions = self::mergeOptions( |
93
|
62 |
|
$priceOptions, |
94
|
|
|
self::makePricingOptionForValidatingCarrier($options->validatingCarrier) |
95
|
155 |
|
); |
96
|
155 |
|
|
97
|
155 |
|
$priceOptions = self::mergeOptions( |
98
|
62 |
|
$priceOptions, |
99
|
|
|
self::makePricingOptionForCurrencyOverride($options->currencyOverride) |
100
|
155 |
|
); |
101
|
155 |
|
|
102
|
155 |
|
$priceOptions = self::mergeOptions( |
103
|
62 |
|
$priceOptions, |
104
|
|
|
self::makePricingOptionFareBasisOverride($options->pricingsFareBasis) |
105
|
155 |
|
); |
106
|
155 |
|
|
107
|
155 |
|
$priceOptions = self::mergeOptions( |
108
|
62 |
|
$priceOptions, |
109
|
|
|
self::makePricingOptionFareFamilyOverride($options->fareFamily) |
|
|
|
|
110
|
155 |
|
); |
111
|
155 |
|
|
112
|
155 |
|
$priceOptions = self::mergeOptions( |
113
|
62 |
|
$priceOptions, |
114
|
|
|
self::loadCorpNegoFare($options->corporateNegoFare) |
115
|
155 |
|
); |
116
|
155 |
|
|
117
|
155 |
|
$priceOptions = self::mergeOptions( |
118
|
62 |
|
$priceOptions, |
119
|
|
|
self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing) |
120
|
155 |
|
); |
121
|
155 |
|
|
122
|
155 |
|
$priceOptions = self::mergeOptions( |
123
|
62 |
|
$priceOptions, |
124
|
|
|
self::loadObFees($options->obFees, $options->obFeeRefs) |
125
|
155 |
|
); |
126
|
155 |
|
|
127
|
155 |
|
$priceOptions = self::mergeOptions( |
128
|
62 |
|
$priceOptions, |
129
|
|
|
self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs) |
130
|
155 |
|
); |
131
|
155 |
|
|
132
|
155 |
|
$priceOptions = self::mergeOptions( |
133
|
155 |
|
$priceOptions, |
134
|
155 |
|
self::loadPointOverrides( |
135
|
62 |
|
$options->pointOfSaleOverride, |
136
|
62 |
|
$options->pointOfTicketingOverride |
137
|
|
|
) |
138
|
155 |
|
); |
139
|
155 |
|
|
140
|
155 |
|
$priceOptions = self::mergeOptions( |
141
|
62 |
|
$priceOptions, |
142
|
|
|
self::loadPricingLogic($options->pricingLogic) |
143
|
155 |
|
); |
144
|
155 |
|
|
145
|
155 |
|
$priceOptions = self::mergeOptions( |
146
|
62 |
|
$priceOptions, |
147
|
|
|
self::loadTicketType($options->ticketType) |
148
|
155 |
|
); |
149
|
155 |
|
|
150
|
155 |
|
$priceOptions = self::mergeOptions( |
151
|
62 |
|
$priceOptions, |
152
|
|
|
self::loadTaxes($options->taxes) |
153
|
155 |
|
); |
154
|
155 |
|
|
155
|
155 |
|
$priceOptions = self::mergeOptions( |
156
|
62 |
|
$priceOptions, |
157
|
|
|
self::loadExemptTaxes($options->exemptTaxes) |
158
|
155 |
|
); |
159
|
155 |
|
|
160
|
155 |
|
$priceOptions = self::mergeOptions( |
161
|
62 |
|
$priceOptions, |
162
|
|
|
self::loadPastDate($options->pastDatePricing) |
163
|
|
|
); |
164
|
155 |
|
|
165
|
155 |
|
|
166
|
155 |
|
$priceOptions = self::mergeOptions( |
167
|
62 |
|
$priceOptions, |
168
|
|
|
self::loadFormOfPayment($options->formOfPayment) |
169
|
155 |
|
); |
170
|
155 |
|
|
171
|
155 |
|
$priceOptions = self::mergeOptions( |
172
|
62 |
|
$priceOptions, |
173
|
|
|
self::loadReferences($options->references) |
174
|
155 |
|
); |
175
|
155 |
|
|
176
|
155 |
|
$priceOptions = self::mergeOptions( |
177
|
62 |
|
$priceOptions, |
178
|
|
|
self::makeOverrideOptions($options->overrideOptions, $priceOptions) |
179
|
155 |
|
); |
180
|
155 |
|
|
181
|
155 |
|
$priceOptions = self::mergeOptions( |
182
|
62 |
|
$priceOptions, |
183
|
|
|
self::makeOverrideOptionsWithCriteria($options->overrideOptionsWithCriteria, $priceOptions) |
184
|
|
|
); |
185
|
155 |
|
|
186
|
30 |
|
$priceOptions = self::mergeOptions( |
187
|
12 |
|
$priceOptions, |
188
|
|
|
self::loadZapOffs($options->zapOff) |
189
|
155 |
|
); |
190
|
|
|
|
191
|
|
|
// All options processed, no options found: |
192
|
|
|
if (empty($priceOptions)) { |
193
|
|
|
$priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
return $priceOptions; |
197
|
155 |
|
} |
198
|
|
|
|
199
|
155 |
|
/** |
200
|
|
|
* @param string[] $overrideOptions |
201
|
155 |
|
* @param PricingOptionGroup[] $priceOptions |
202
|
40 |
|
* @return PricingOptionGroup[] |
203
|
40 |
|
*/ |
204
|
16 |
View Code Duplication |
protected static function makeOverrideOptions($overrideOptions, $priceOptions) |
|
|
|
|
205
|
62 |
|
{ |
206
|
|
|
$opt = []; |
207
|
155 |
|
|
208
|
|
|
foreach ($overrideOptions as $overrideOption) { |
209
|
|
|
if (!self::hasPricingGroup($overrideOption, $priceOptions)) { |
210
|
|
|
$opt[] = new PricingOptionGroup($overrideOption); |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
return $opt; |
215
|
155 |
|
} |
216
|
|
|
|
217
|
155 |
|
/** |
218
|
|
|
* @param string[] $overrideOptionsWithCriteria |
219
|
155 |
|
* @param PricingOptionGroup[] $priceOptions |
220
|
5 |
|
* @return PricingOptionGroup[] |
221
|
5 |
|
*/ |
222
|
2 |
|
protected static function makeOverrideOptionsWithCriteria($overrideOptionsWithCriteria, $priceOptions) |
223
|
62 |
|
{ |
224
|
|
|
$opt = []; |
225
|
155 |
|
|
226
|
|
|
foreach ($overrideOptionsWithCriteria as $overrideOptionWithCriteria) { |
227
|
|
|
if (!self::hasPricingGroup($overrideOptionWithCriteria["key"], $priceOptions)) { |
228
|
|
|
$opt[] = new PricingOptionGroup($overrideOptionWithCriteria["key"], $overrideOptionWithCriteria["optionDetail"]); |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
232
|
155 |
|
return $opt; |
233
|
|
|
} |
234
|
155 |
|
|
235
|
|
|
/** |
236
|
155 |
|
* @param string|null $validatingCarrier |
237
|
40 |
|
* @return PricePnr13\PricingOptionGroup[] |
238
|
|
|
*/ |
239
|
40 |
View Code Duplication |
protected static function makePricingOptionForValidatingCarrier($validatingCarrier) |
|
|
|
|
240
|
|
|
{ |
241
|
40 |
|
$opt = []; |
242
|
16 |
|
|
243
|
|
|
if ($validatingCarrier !== null) { |
244
|
155 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER); |
245
|
|
|
|
246
|
|
|
$po->carrierInformation = new CarrierInformation($validatingCarrier); |
247
|
|
|
|
248
|
|
|
$opt[] = $po; |
249
|
|
|
} |
250
|
|
|
|
251
|
155 |
|
return $opt; |
252
|
|
|
} |
253
|
155 |
|
|
254
|
|
|
/** |
255
|
155 |
|
* @param string|null $currency |
256
|
40 |
|
* @return PricePnr13\PricingOptionGroup[] |
257
|
|
|
*/ |
258
|
40 |
View Code Duplication |
protected static function makePricingOptionForCurrencyOverride($currency) |
|
|
|
|
259
|
|
|
{ |
260
|
40 |
|
$opt = []; |
261
|
16 |
|
|
262
|
|
|
if ($currency !== null) { |
263
|
155 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE); |
264
|
|
|
|
265
|
|
|
$po->currency = new Currency($currency); |
266
|
|
|
|
267
|
|
|
$opt[] = $po; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
return $opt; |
271
|
155 |
|
} |
272
|
|
|
|
273
|
155 |
|
|
274
|
|
|
/** |
275
|
155 |
|
* @param FareBasis[] $pricingsFareBasis |
276
|
155 |
|
* @return PricePnr13\PricingOptionGroup[] |
277
|
20 |
|
*/ |
278
|
|
View Code Duplication |
protected static function makePricingOptionFareBasisOverride($pricingsFareBasis) |
|
|
|
|
279
|
|
|
{ |
280
|
20 |
|
$opt = []; |
281
|
20 |
|
|
282
|
8 |
|
if ($pricingsFareBasis !== null) { |
283
|
|
|
foreach ($pricingsFareBasis as $pricingFareBasis) { |
284
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE); |
285
|
20 |
|
|
286
|
20 |
|
//Support for legacy fareBasisPrimaryCode to be removed when breaking BC: |
287
|
20 |
|
$po->optionDetail = new OptionDetail( |
288
|
8 |
|
$pricingFareBasis->fareBasisPrimaryCode.$pricingFareBasis->fareBasisCode |
|
|
|
|
289
|
|
|
); |
290
|
20 |
|
|
291
|
62 |
|
//Support for legacy segmentReference to be removed when breaking BC: |
292
|
62 |
|
$po->paxSegTstReference = new PaxSegTstReference( |
293
|
|
|
$pricingFareBasis->references, |
294
|
155 |
|
$pricingFareBasis->segmentReference |
|
|
|
|
295
|
|
|
); |
296
|
|
|
|
297
|
|
|
$opt[] = $po; |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
return $opt; |
302
|
|
|
} |
303
|
155 |
|
|
304
|
|
|
/** |
305
|
155 |
|
* Load fare-family pricing option and return it. |
306
|
|
|
* |
307
|
155 |
|
* @param string $fareFamily input fare-family, e.g. "CLASSIC" |
308
|
5 |
|
* @return PricePnr13\PricingOptionGroup[] |
309
|
5 |
|
*/ |
310
|
|
|
protected static function makePricingOptionFareFamilyOverride($fareFamily) |
311
|
5 |
|
{ |
312
|
2 |
|
$opt = []; |
313
|
|
|
|
314
|
155 |
|
if ($fareFamily !== null) { |
315
|
|
|
if (is_array($fareFamily)) { |
316
|
|
|
/** |
317
|
|
|
* @var FareFamily $item |
318
|
|
|
*/ |
319
|
|
View Code Duplication |
foreach ($fareFamily as $item) { |
|
|
|
|
320
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_FAMILY); |
321
|
|
|
$po->optionDetail = new OptionDetail([['FF' => $item->fareFamily]]); |
322
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($item->paxSegRefs); |
323
|
155 |
|
|
324
|
|
|
$opt[] = $po; |
325
|
155 |
|
} |
326
|
|
|
} else { |
327
|
155 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_FAMILY); |
328
|
5 |
|
$po->optionDetail = new OptionDetail([['FF' => $fareFamily]]); |
329
|
|
|
|
330
|
5 |
|
$opt[] = $po; |
331
|
|
|
} |
332
|
5 |
|
} |
333
|
2 |
|
|
334
|
|
|
return $opt; |
335
|
155 |
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Load corporate negofare |
339
|
|
|
* |
340
|
|
|
* @param string|null $corporateNegoFare |
341
|
|
|
* @return PricingOptionGroup[] |
342
|
|
|
*/ |
343
|
|
View Code Duplication |
protected static function loadCorpNegoFare($corporateNegoFare) |
|
|
|
|
344
|
|
|
{ |
345
|
155 |
|
$opt = []; |
346
|
|
|
|
347
|
155 |
|
if ($corporateNegoFare !== null) { |
348
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES); |
349
|
155 |
|
|
350
|
10 |
|
$po->optionDetail = new OptionDetail($corporateNegoFare); |
351
|
10 |
|
|
352
|
10 |
|
$opt[] = $po; |
353
|
|
|
} |
354
|
10 |
|
|
355
|
5 |
|
return $opt; |
356
|
2 |
|
} |
357
|
4 |
|
|
358
|
|
|
/** |
359
|
155 |
|
* Load corporate unifares |
360
|
|
|
* |
361
|
|
|
* @param string[] $corporateUniFares |
362
|
|
|
* @param AwardPricing|null $awardPricing |
363
|
|
|
* @return PricingOptionGroup[] |
364
|
|
|
*/ |
365
|
|
|
protected static function loadCorpUniFares($corporateUniFares, $awardPricing) |
366
|
5 |
|
{ |
367
|
|
|
$opt = []; |
368
|
5 |
|
|
369
|
|
|
if (!empty($corporateUniFares)) { |
370
|
5 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES); |
371
|
|
|
$po->optionDetail = new OptionDetail($corporateUniFares); |
372
|
5 |
|
$opt[] = $po; |
373
|
5 |
|
|
374
|
5 |
|
if (!empty($awardPricing)) { |
375
|
2 |
|
$opt[] = self::loadAwardPricing($awardPricing); |
376
|
|
|
} |
377
|
5 |
|
} |
378
|
|
|
|
379
|
|
|
return $opt; |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @param AwardPricing $awardPricing |
384
|
|
|
* @return PricingOptionGroup |
385
|
|
|
*/ |
386
|
|
View Code Duplication |
protected static function loadAwardPricing($awardPricing) |
|
|
|
|
387
|
155 |
|
{ |
388
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING); |
389
|
155 |
|
|
390
|
|
|
$po->carrierInformation = new CarrierInformation($awardPricing->carrier); |
391
|
155 |
|
|
392
|
5 |
|
$po->frequentFlyerInformation = new FrequentFlyerInformation(); |
393
|
|
|
$po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails( |
394
|
5 |
|
$awardPricing->tierLevel |
395
|
5 |
|
); |
396
|
2 |
|
|
397
|
2 |
|
return $po; |
398
|
|
|
} |
399
|
5 |
|
|
400
|
5 |
|
/** |
401
|
2 |
|
* Load OB Fees |
402
|
|
|
* |
403
|
5 |
|
* @param ObFee[] $obFees |
404
|
2 |
|
* @param PaxSegRef[] $obFeeRefs |
405
|
|
|
* @return PricingOptionGroup[] |
406
|
155 |
|
*/ |
407
|
|
View Code Duplication |
protected static function loadObFees($obFees, $obFeeRefs) |
|
|
|
|
408
|
|
|
{ |
409
|
|
|
$opt = []; |
410
|
|
|
|
411
|
|
|
if (!empty($obFees)) { |
412
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES); |
413
|
|
|
|
414
|
155 |
|
$po->penDisInformation = new PenDisInformation( |
415
|
|
|
PenDisInformation::QUAL_OB_FEES, |
416
|
155 |
|
$obFees |
417
|
|
|
); |
418
|
155 |
|
|
419
|
20 |
|
if (!empty($obFeeRefs)) { |
420
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($obFeeRefs); |
421
|
20 |
|
} |
422
|
20 |
|
|
423
|
8 |
|
$opt[] = $po; |
424
|
8 |
|
} |
425
|
|
|
|
426
|
20 |
|
return $opt; |
427
|
20 |
|
} |
428
|
8 |
|
|
429
|
|
|
/** |
430
|
20 |
|
* @param string[] $paxDiscount |
431
|
8 |
|
* @param PaxSegRef[] $paxDiscountCodeRefs |
432
|
|
|
* @return PricingOptionGroup[] |
433
|
155 |
|
*/ |
434
|
|
View Code Duplication |
protected static function loadPaxDiscount($paxDiscount, $paxDiscountCodeRefs) |
|
|
|
|
435
|
|
|
{ |
436
|
|
|
$opt = []; |
437
|
|
|
|
438
|
|
|
if (!empty($paxDiscount)) { |
439
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC); |
440
|
|
|
|
441
|
155 |
|
$po->penDisInformation = new PenDisInformation( |
442
|
|
|
PenDisInformation::QUAL_DISCOUNT, |
443
|
155 |
|
$paxDiscount |
444
|
|
|
); |
445
|
155 |
|
|
446
|
5 |
|
if (!empty($paxDiscountCodeRefs)) { |
447
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($paxDiscountCodeRefs); |
448
|
5 |
|
} |
449
|
5 |
|
|
450
|
2 |
|
$opt[] = $po; |
451
|
2 |
|
} |
452
|
|
|
|
453
|
5 |
|
return $opt; |
454
|
2 |
|
} |
455
|
|
|
|
456
|
155 |
|
/** |
457
|
5 |
|
* @param string|null $posOverride |
458
|
|
|
* @param string|null $potOverride |
459
|
5 |
|
* @return PricingOptionGroup[] |
460
|
5 |
|
*/ |
461
|
2 |
View Code Duplication |
protected static function loadPointOverrides($posOverride, $potOverride) |
|
|
|
|
462
|
2 |
|
{ |
463
|
|
|
$opt = []; |
464
|
5 |
|
|
465
|
2 |
|
if (!empty($posOverride)) { |
466
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE); |
467
|
155 |
|
|
468
|
|
|
$po->locationInformation = new LocationInformation( |
469
|
|
|
LocationInformation::TYPE_POINT_OF_SALE, |
470
|
|
|
$posOverride |
471
|
|
|
); |
472
|
|
|
|
473
|
|
|
$opt[] = $po; |
474
|
155 |
|
} |
475
|
|
|
|
476
|
155 |
|
if (!empty($potOverride)) { |
477
|
|
|
$po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE); |
478
|
155 |
|
|
479
|
5 |
|
$po2->locationInformation = new LocationInformation( |
480
|
5 |
|
LocationInformation::TYPE_POINT_OF_TICKETING, |
481
|
5 |
|
$potOverride |
482
|
2 |
|
); |
483
|
|
|
|
484
|
155 |
|
$opt[] = $po2; |
485
|
|
|
} |
486
|
|
|
|
487
|
|
|
return $opt; |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
155 |
|
* @param string|null $pricingLogic |
492
|
|
|
* @return PricingOptionGroup[] |
493
|
155 |
|
*/ |
494
|
|
View Code Duplication |
protected static function loadPricingLogic($pricingLogic) |
|
|
|
|
495
|
155 |
|
{ |
496
|
5 |
|
$opt = []; |
497
|
|
|
|
498
|
5 |
|
if (!empty($pricingLogic)) { |
499
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC); |
500
|
5 |
|
$po->optionDetail = new OptionDetail($pricingLogic); |
501
|
2 |
|
$opt[] = $po; |
502
|
|
|
} |
503
|
155 |
|
|
504
|
|
|
return $opt; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* @param string|null $ticketType |
509
|
|
|
* @return PricingOptionGroup[] |
510
|
155 |
|
*/ |
511
|
|
View Code Duplication |
protected static function loadTicketType($ticketType) |
|
|
|
|
512
|
155 |
|
{ |
513
|
|
|
$opt = []; |
514
|
155 |
|
|
515
|
5 |
|
if (!empty($ticketType)) { |
516
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE); |
517
|
5 |
|
|
518
|
5 |
|
$po->optionDetail = new OptionDetail($ticketType); |
519
|
5 |
|
|
520
|
|
|
$opt[] = $po; |
521
|
5 |
|
} |
522
|
5 |
|
|
523
|
5 |
|
return $opt; |
524
|
4 |
|
} |
525
|
2 |
|
|
526
|
2 |
|
/** |
527
|
2 |
|
* @param Tax[] $taxes |
528
|
5 |
|
* @return PricingOptionGroup[] |
529
|
2 |
|
*/ |
530
|
|
View Code Duplication |
protected static function loadTaxes($taxes) |
|
|
|
|
531
|
155 |
|
{ |
532
|
|
|
$opt = []; |
533
|
|
|
|
534
|
|
|
if (!empty($taxes)) { |
535
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX); |
536
|
|
|
|
537
|
|
|
foreach ($taxes as $tax) { |
538
|
155 |
|
$qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE; |
539
|
|
|
$rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage; |
540
|
155 |
|
|
541
|
|
|
$po->taxInformation[] = new TaxInformation( |
542
|
155 |
|
$tax->countryCode, |
543
|
5 |
|
$tax->taxNature, |
544
|
|
|
$qualifier, |
545
|
5 |
|
$rate |
546
|
5 |
|
); |
547
|
5 |
|
} |
548
|
5 |
|
$opt[] = $po; |
549
|
2 |
|
} |
550
|
2 |
|
|
551
|
|
|
return $opt; |
552
|
5 |
|
} |
553
|
2 |
|
|
554
|
|
|
/** |
555
|
155 |
|
* @param ExemptTax[] $exemptTaxes |
556
|
|
|
* @return PricingOptionGroup[] |
557
|
|
|
*/ |
558
|
|
View Code Duplication |
protected static function loadExemptTaxes($exemptTaxes) |
|
|
|
|
559
|
|
|
{ |
560
|
|
|
$opt = []; |
561
|
|
|
|
562
|
155 |
|
if (!empty($exemptTaxes)) { |
563
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX); |
564
|
155 |
|
|
565
|
|
|
foreach ($exemptTaxes as $tax) { |
566
|
155 |
|
$po->taxInformation[] = new TaxInformation( |
567
|
5 |
|
$tax->countryCode, |
568
|
|
|
$tax->taxNature |
569
|
5 |
|
); |
570
|
5 |
|
} |
571
|
2 |
|
|
572
|
2 |
|
$opt[] = $po; |
573
|
|
|
} |
574
|
5 |
|
|
575
|
2 |
|
return $opt; |
576
|
|
|
} |
577
|
155 |
|
|
578
|
|
|
/** |
579
|
|
|
* @param \DateTime|null $pastDate |
580
|
|
|
* @return PricingOptionGroup[] |
581
|
|
|
*/ |
582
|
|
View Code Duplication |
protected static function loadPastDate($pastDate) |
|
|
|
|
583
|
|
|
{ |
584
|
|
|
$opt = []; |
585
|
155 |
|
|
586
|
|
|
if ($pastDate instanceof \DateTime) { |
587
|
155 |
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING); |
588
|
|
|
|
589
|
155 |
|
$po->dateInformation = new DateInformation( |
590
|
5 |
|
DateInformation::OPT_DATE_OVERRIDE, |
591
|
|
|
$pastDate |
592
|
5 |
|
); |
593
|
|
|
|
594
|
5 |
|
$opt[] = $po; |
595
|
2 |
|
} |
596
|
|
|
|
597
|
155 |
|
return $opt; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* @param FormOfPayment[] $formOfPayment |
603
|
|
|
* @return PricingOptionGroup[] |
604
|
155 |
|
*/ |
605
|
|
View Code Duplication |
protected static function loadFormOfPayment($formOfPayment) |
|
|
|
|
606
|
155 |
|
{ |
607
|
|
|
$opt = []; |
608
|
155 |
|
|
609
|
5 |
|
if (!empty($formOfPayment)) { |
610
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT); |
611
|
5 |
|
|
612
|
|
|
$po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment); |
613
|
5 |
|
|
614
|
2 |
|
$opt[] = $po; |
615
|
|
|
} |
616
|
155 |
|
|
617
|
|
|
return $opt; |
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
/** |
621
|
|
|
* @param PaxSegRef[] $references |
622
|
|
|
* @return PricingOptionGroup[] |
623
|
|
|
*/ |
624
|
|
View Code Duplication |
protected static function loadReferences($references) |
|
|
|
|
625
|
|
|
{ |
626
|
|
|
$opt = []; |
627
|
|
|
|
628
|
|
|
if (!empty($references)) { |
629
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION); |
630
|
|
|
|
631
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($references); |
632
|
|
|
|
633
|
|
|
$opt[] = $po; |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
return $opt; |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
/** |
640
|
|
|
* Load ZAP-Off |
641
|
|
|
* |
642
|
|
|
* @param ZapOff[] $zapOffs |
643
|
|
|
* @return PricingOptionGroup[] |
644
|
|
|
*/ |
645
|
|
|
protected static function loadZapOffs($zapOffs) |
646
|
|
|
{ |
647
|
|
|
$opt = []; |
648
|
|
|
if (!empty($zapOffs)) { |
649
|
|
View Code Duplication |
foreach ($zapOffs as $zapOff) { |
|
|
|
|
650
|
|
|
$po = new PricingOptionGroup(PricingOptionKey::OPTION_ZAP_OFF); |
651
|
|
|
|
652
|
|
|
$po->penDisInformation = new PenDisInformation( |
653
|
|
|
PenDisInformation::QUAL_ZAPOFF_DISCOUNT, |
654
|
|
|
[$zapOff] |
655
|
|
|
); |
656
|
|
|
|
657
|
|
|
if (!empty($zapOff->paxSegRefs)) { |
658
|
|
|
$po->paxSegTstReference = new PaxSegTstReference($zapOff->paxSegRefs); |
659
|
|
|
} |
660
|
|
|
|
661
|
|
|
$opt[] = $po; |
662
|
|
|
} |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
return $opt; |
666
|
|
|
} |
667
|
|
|
} |
668
|
|
|
|
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.