makePricingOptionForCurrencyOverride()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 1
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\FormOfPayment;
30
use Amadeus\Client\RequestOptions\Fare\PricePnr\ObFee;
31
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef;
32
use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax;
33
use Amadeus\Client\RequestOptions\Fare\PricePnr\ZapOff;
34
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions;
35
use Amadeus\Client\RequestOptions\FarePricePnrWithLowerFaresOptions as LowerFareOpt;
36
use Amadeus\Client\RequestOptions\FarePricePnrWithLowestFareOptions as LowestFareOpt;
37
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions as InformativePriceOpt;
38
use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation;
39
use Amadeus\Client\Struct\Fare\PricePnr13\Currency;
40
use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation;
41
use Amadeus\Client\Struct\Fare\PricePnr13\FormOfPaymentInformation;
42
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation;
43
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentTravellerDetails;
44
use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation;
45
use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail;
46
use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference;
47
use Amadeus\Client\Struct\Fare\PricePnr13\PenDisInformation;
48
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup;
49
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionKey;
50
use Amadeus\Client\Struct\Fare\PricePnr13\TaxData;
51
use Amadeus\Client\Struct\Fare\PricePnr13\TaxInformation;
52
53
/**
54
 * Fare_PricePNRWithBookingClass v 13 and higher structure
55
 *
56
 * @package Amadeus\Client\Struct\Fare
57
 * @author dieter <[email protected]>
58
 */
59
class PricePNRWithBookingClass13 extends BasePricingMessage
60
{
61
    /**
62
     * @var PricePnr13\PricingOptionGroup[]
63
     */
64
    public $pricingOptionGroup = [];
65
66
    /**
67
     * PricePNRWithBookingClass13 constructor.
68
     *
69
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|InformativePriceOpt|null $options
70
     * @throws MessageVersionUnsupportedException
71
     */
72
    public function __construct($options)
73
    {
74
        if (!is_null($options)) {
75
            $this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options);
76
        }
77
    }
78
79
    /**
80
     * Load an array of PricingOptionGroup objects from the Pricing request options.
81
     *
82
     * Extracted because this method is also used in the InformativePricingWithoutPnr messages.
83
     *
84
     * @param FarePricePnrWithBookingClassOptions|LowerFareOpt|LowestFareOpt|InformativePriceOpt $options
85
     * @return PricingOptionGroup[]
86
     */
87
    public static function loadPricingOptionsFromRequestOptions($options)
88
    {
89
        $priceOptions = [];
90
91
        $priceOptions = self::mergeOptions(
92
            $priceOptions,
93
            self::makePricingOptionForValidatingCarrier($options->validatingCarrier)
94
        );
95
96
        $priceOptions = self::mergeOptions(
97
            $priceOptions,
98
            self::makePricingOptionForCurrencyOverride($options->currencyOverride)
99
        );
100
101
        $priceOptions = self::mergeOptions(
102
            $priceOptions,
103
            self::makePricingOptionFareBasisOverride($options->pricingsFareBasis)
104
        );
105
106
        $priceOptions = self::mergeOptions(
107
            $priceOptions,
108
            self::makePricingOptionFareFamilyOverride($options->fareFamily)
109
        );
110
111
        $priceOptions = self::mergeOptions(
112
            $priceOptions,
113
            self::loadCorpNegoFare($options->corporateNegoFare)
114
        );
115
116
        $priceOptions = self::mergeOptions(
117
            $priceOptions,
118
            self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing)
119
        );
120
121
        $priceOptions = self::mergeOptions(
122
            $priceOptions,
123
            self::loadObFees($options->obFees, $options->obFeeRefs)
124
        );
125
126
        $priceOptions = self::mergeOptions(
127
            $priceOptions,
128
            self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs)
129
        );
130
131
        $priceOptions = self::mergeOptions(
132
            $priceOptions,
133
            self::loadPointOverrides(
134
                $options->pointOfSaleOverride,
135
                $options->pointOfTicketingOverride
136
            )
137
        );
138
139
        $priceOptions = self::mergeOptions(
140
            $priceOptions,
141
            self::loadPricingLogic($options->pricingLogic)
142
        );
143
144
        $priceOptions = self::mergeOptions(
145
            $priceOptions,
146
            self::loadTicketType($options->ticketType)
147
        );
148
149
        $priceOptions = self::mergeOptions(
150
            $priceOptions,
151
            self::loadTaxes($options->taxes)
152
        );
153
154
        $priceOptions = self::mergeOptions(
155
            $priceOptions,
156
            self::loadExemptTaxes($options->exemptTaxes)
157
        );
158
159
        $priceOptions = self::mergeOptions(
160
            $priceOptions,
161
            self::loadPastDate($options->pastDatePricing)
162
        );
163
164
165
        $priceOptions = self::mergeOptions(
166
            $priceOptions,
167
            self::loadFormOfPayment($options->formOfPayment)
168
        );
169
170
        $priceOptions = self::mergeOptions(
171
            $priceOptions,
172
            self::loadReferences($options->references)
173
        );
174
175
        $priceOptions = self::mergeOptions(
176
            $priceOptions,
177
            self::makeOverrideOptions($options->overrideOptions, $priceOptions)
178
        );
179
180
        $priceOptions = self::mergeOptions(
181
            $priceOptions,
182
            self::makeOverrideOptionsWithCriteria($options->overrideOptionsWithCriteria, $priceOptions)
183
        );
184
185
        $priceOptions = self::mergeOptions(
186
            $priceOptions,
187
            self::loadZapOffs($options->zapOff)
188
        );
189
190
        // All options processed, no options found:
191
        if (empty($priceOptions)) {
192
            $priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
193
        }
194
195
        return $priceOptions;
196
    }
197
198
    /**
199
     * @param string[] $overrideOptions
200
     * @param PricingOptionGroup[] $priceOptions
201
     * @return PricingOptionGroup[]
202
     */
203 View Code Duplication
    protected static function makeOverrideOptions($overrideOptions, $priceOptions)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
204
    {
205
        $opt = [];
206
207
        foreach ($overrideOptions as $overrideOption) {
208
            if (!self::hasPricingGroup($overrideOption, $priceOptions)) {
209
                $opt[] = new PricingOptionGroup($overrideOption);
210
            }
211
        }
212
213
        return $opt;
214
    }
215
216
    /**
217
     * @param string[] $overrideOptionsWithCriteria
218
     * @param PricingOptionGroup[] $priceOptions
219
     * @return PricingOptionGroup[]
220
     */
221
    protected static function makeOverrideOptionsWithCriteria($overrideOptionsWithCriteria, $priceOptions)
222
    {
223
        $opt = [];
224
225
        foreach ($overrideOptionsWithCriteria as $overrideOptionWithCriteria) {
226
            if (!self::hasPricingGroup($overrideOptionWithCriteria["key"], $priceOptions)) {
227
                $opt[] = new PricingOptionGroup($overrideOptionWithCriteria["key"], $overrideOptionWithCriteria["optionDetail"]);
228
            }
229
        }
230
231
        return $opt;
232
    }
233
234
    /**
235
     * @param string|null $validatingCarrier
236
     * @return PricePnr13\PricingOptionGroup[]
237
     */
238 View Code Duplication
    protected static function makePricingOptionForValidatingCarrier($validatingCarrier)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
239
    {
240
        $opt = [];
241
242
        if ($validatingCarrier !== null) {
243
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER);
244
245
            $po->carrierInformation = new CarrierInformation($validatingCarrier);
246
247
            $opt[] = $po;
248
        }
249
250
        return $opt;
251
    }
252
253
    /**
254
     * @param string|null $currency
255
     * @return PricePnr13\PricingOptionGroup[]
256
     */
257 View Code Duplication
    protected static function makePricingOptionForCurrencyOverride($currency)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
258
    {
259
        $opt = [];
260
261
        if ($currency !== null) {
262
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE);
263
264
            $po->currency = new Currency($currency);
265
266
            $opt[] = $po;
267
        }
268
269
        return $opt;
270
    }
271
272
273
    /**
274
     * @param FareBasis[] $pricingsFareBasis
275
     * @return PricePnr13\PricingOptionGroup[]
276
     */
277 View Code Duplication
    protected static function makePricingOptionFareBasisOverride($pricingsFareBasis)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
278
    {
279
        $opt = [];
280
281
        if ($pricingsFareBasis !== null) {
282
            foreach ($pricingsFareBasis as $pricingFareBasis) {
283
                $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE);
284
285
                //Support for legacy fareBasisPrimaryCode to be removed when breaking BC:
286
                $po->optionDetail = new OptionDetail(
287
                    $pricingFareBasis->fareBasisPrimaryCode.$pricingFareBasis->fareBasisCode
0 ignored issues
show
Deprecated Code introduced by
The property Amadeus\Client\RequestOp...::$fareBasisPrimaryCode has been deprecated with message: put the full fare basis in $this->fareBasisCode

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
288
                );
289
290
                //Support for legacy segmentReference to be removed when breaking BC:
291
                $po->paxSegTstReference = new PaxSegTstReference(
292
                    $pricingFareBasis->references,
293
                    $pricingFareBasis->segmentReference
0 ignored issues
show
Deprecated Code introduced by
The property Amadeus\Client\RequestOp...asis::$segmentReference has been deprecated with message: use $this->references instead

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
294
                );
295
296
                $opt[] = $po;
297
            }
298
        }
299
300
        return $opt;
301
    }
302
303
    /**
304
     * Load fare-family pricing option and return it.
305
     *
306
     * @param string $fareFamily input fare-family, e.g. "CLASSIC"
307
     * @return PricePnr13\PricingOptionGroup[]
308
     */
309
    protected static function makePricingOptionFareFamilyOverride($fareFamily)
310
    {
311
        $opt = [];
312
313
        if ($fareFamily !== null) {
314
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_FAMILY);
315
            $po->optionDetail = new OptionDetail([['FF' => $fareFamily]]);
316
317
            $opt[] = $po;
318
        }
319
320
        return $opt;
321
    }
322
323
    /**
324
     * Load corporate negofare
325
     *
326
     * @param string|null $corporateNegoFare
327
     * @return PricingOptionGroup[]
328
     */
329 View Code Duplication
    protected static function loadCorpNegoFare($corporateNegoFare)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
330
    {
331
        $opt = [];
332
333
        if ($corporateNegoFare !== null) {
334
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES);
335
336
            $po->optionDetail = new OptionDetail($corporateNegoFare);
337
338
            $opt[] = $po;
339
        }
340
341
        return $opt;
342
    }
343
344
    /**
345
     * Load corporate unifares
346
     *
347
     * @param string[] $corporateUniFares
348
     * @param AwardPricing|null $awardPricing
349
     * @return PricingOptionGroup[]
350
     */
351
    protected static function loadCorpUniFares($corporateUniFares, $awardPricing)
352
    {
353
        $opt = [];
354
355
        if (!empty($corporateUniFares)) {
356
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES);
357
            $po->optionDetail = new OptionDetail($corporateUniFares);
358
            $opt[] = $po;
359
360
            if (!empty($awardPricing)) {
361
                $opt[] = self::loadAwardPricing($awardPricing);
362
            }
363
        }
364
365
        return $opt;
366
    }
367
368
    /**
369
     * @param AwardPricing $awardPricing
370
     * @return PricingOptionGroup
371
     */
372 View Code Duplication
    protected static function loadAwardPricing($awardPricing)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
373
    {
374
        $po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING);
375
376
        $po->carrierInformation = new CarrierInformation($awardPricing->carrier);
377
378
        $po->frequentFlyerInformation = new FrequentFlyerInformation();
379
        $po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails(
380
            $awardPricing->tierLevel
381
        );
382
383
        return $po;
384
    }
385
386
    /**
387
     * Load OB Fees
388
     *
389
     * @param ObFee[] $obFees
390
     * @param PaxSegRef[] $obFeeRefs
391
     * @return PricingOptionGroup[]
392
     */
393 View Code Duplication
    protected static function loadObFees($obFees, $obFeeRefs)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
394
    {
395
        $opt = [];
396
397
        if (!empty($obFees)) {
398
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES);
399
400
            $po->penDisInformation = new PenDisInformation(
401
                PenDisInformation::QUAL_OB_FEES,
402
                $obFees
403
            );
404
405
            if (!empty($obFeeRefs)) {
406
                $po->paxSegTstReference = new PaxSegTstReference($obFeeRefs);
407
            }
408
409
            $opt[] = $po;
410
        }
411
412
        return $opt;
413
    }
414
415
    /**
416
     * @param string[] $paxDiscount
417
     * @param PaxSegRef[] $paxDiscountCodeRefs
418
     * @return PricingOptionGroup[]
419
     */
420 View Code Duplication
    protected static function loadPaxDiscount($paxDiscount, $paxDiscountCodeRefs)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
421
    {
422
        $opt = [];
423
424
        if (!empty($paxDiscount)) {
425
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC);
426
427
            $po->penDisInformation = new PenDisInformation(
428
                PenDisInformation::QUAL_DISCOUNT,
429
                $paxDiscount
430
            );
431
432
            if (!empty($paxDiscountCodeRefs)) {
433
                $po->paxSegTstReference = new PaxSegTstReference($paxDiscountCodeRefs);
434
            }
435
436
            $opt[] = $po;
437
        }
438
439
        return $opt;
440
    }
441
442
    /**
443
     * @param string|null $posOverride
444
     * @param string|null $potOverride
445
     * @return PricingOptionGroup[]
446
     */
447 View Code Duplication
    protected static function loadPointOverrides($posOverride, $potOverride)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448
    {
449
        $opt = [];
450
451
        if (!empty($posOverride)) {
452
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE);
453
454
            $po->locationInformation = new LocationInformation(
455
                LocationInformation::TYPE_POINT_OF_SALE,
456
                $posOverride
457
            );
458
459
            $opt[] = $po;
460
        }
461
462
        if (!empty($potOverride)) {
463
            $po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE);
464
465
            $po2->locationInformation = new LocationInformation(
466
                LocationInformation::TYPE_POINT_OF_TICKETING,
467
                $potOverride
468
            );
469
470
            $opt[] = $po2;
471
        }
472
473
        return $opt;
474
    }
475
476
    /**
477
     * @param string|null $pricingLogic
478
     * @return PricingOptionGroup[]
479
     */
480 View Code Duplication
    protected static function loadPricingLogic($pricingLogic)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
481
    {
482
        $opt = [];
483
484
        if (!empty($pricingLogic)) {
485
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC);
486
            $po->optionDetail = new OptionDetail($pricingLogic);
487
            $opt[] = $po;
488
        }
489
490
        return $opt;
491
    }
492
493
    /**
494
     * @param string|null $ticketType
495
     * @return PricingOptionGroup[]
496
     */
497 View Code Duplication
    protected static function loadTicketType($ticketType)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
498
    {
499
        $opt = [];
500
501
        if (!empty($ticketType)) {
502
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE);
503
504
            $po->optionDetail = new OptionDetail($ticketType);
505
506
            $opt[] = $po;
507
        }
508
509
        return $opt;
510
    }
511
512
    /**
513
     * @param Tax[] $taxes
514
     * @return PricingOptionGroup[]
515
     */
516 View Code Duplication
    protected static function loadTaxes($taxes)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
517
    {
518
        $opt = [];
519
520
        if (!empty($taxes)) {
521
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX);
522
523
            foreach ($taxes as $tax) {
524
                $qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE;
525
                $rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage;
526
527
                $po->taxInformation[] = new TaxInformation(
528
                    $tax->countryCode,
529
                    $tax->taxNature,
530
                    $qualifier,
531
                    $rate
532
                );
533
            }
534
            $opt[] = $po;
535
        }
536
537
        return $opt;
538
    }
539
540
    /**
541
     * @param ExemptTax[] $exemptTaxes
542
     * @return PricingOptionGroup[]
543
     */
544 View Code Duplication
    protected static function loadExemptTaxes($exemptTaxes)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
545
    {
546
        $opt = [];
547
548
        if (!empty($exemptTaxes)) {
549
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX);
550
551
            foreach ($exemptTaxes as $tax) {
552
                $po->taxInformation[] = new TaxInformation(
553
                    $tax->countryCode,
554
                    $tax->taxNature
555
                );
556
            }
557
558
            $opt[] = $po;
559
        }
560
561
        return $opt;
562
    }
563
564
    /**
565
     * @param \DateTime|null $pastDate
566
     * @return PricingOptionGroup[]
567
     */
568 View Code Duplication
    protected static function loadPastDate($pastDate)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
569
    {
570
        $opt = [];
571
572
        if ($pastDate instanceof \DateTime) {
573
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING);
574
575
            $po->dateInformation = new DateInformation(
576
                DateInformation::OPT_DATE_OVERRIDE,
577
                $pastDate
578
            );
579
580
            $opt[] = $po;
581
        }
582
583
        return $opt;
584
    }
585
586
587
    /**
588
     * @param FormOfPayment[] $formOfPayment
589
     * @return PricingOptionGroup[]
590
     */
591 View Code Duplication
    protected static function loadFormOfPayment($formOfPayment)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
592
    {
593
        $opt = [];
594
595
        if (!empty($formOfPayment)) {
596
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT);
597
598
            $po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment);
599
600
            $opt[] = $po;
601
        }
602
603
        return $opt;
604
    }
605
606
    /**
607
     * @param PaxSegRef[] $references
608
     * @return PricingOptionGroup[]
609
     */
610 View Code Duplication
    protected static function loadReferences($references)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
611
    {
612
        $opt = [];
613
614
        if (!empty($references)) {
615
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION);
616
617
            $po->paxSegTstReference = new PaxSegTstReference($references);
618
619
            $opt[] = $po;
620
        }
621
622
        return $opt;
623
    }
624
625
    /**
626
     * Load ZAP-Off
627
     *
628
     * @param ZapOff[] $zapOffs
629
     * @return PricingOptionGroup[]
630
     */
631
    protected static function loadZapOffs($zapOffs)
632
    {
633
        $opt = [];
634
        if (!empty($zapOffs)) {
635
            foreach ($zapOffs as $zapOff) {
636
                $po = new PricingOptionGroup(PricingOptionKey::OPTION_ZAP_OFF);
637
638
                $po->penDisInformation = new PenDisInformation(
639
                    PenDisInformation::QUAL_ZAPOFF_DISCOUNT,
640
                    [$zapOff]
641
                );
642
643
                if (!empty($zapOff->paxSegRefs)) {
644
                    $po->paxSegTstReference = new PaxSegTstReference($zapOff->paxSegRefs);
645
                }
646
647
                $opt[] = $po;
648
            }
649
        }
650
651
        return $opt;
652
    }
653
}
654