Completed
Push — master ( 0447dc...4c246c )
by Dieter
09:17
created

makeOverrideOptionsWithCriteria()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

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

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
217 2
            }
218 60
        }
219
220 120
        return $opt;
221
    }
222
223
    /**
224
     * @param string|null $validatingCarrier
225
     * @return PricePnr13\PricingOptionGroup[]
226
     */
227 120 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...
228
    {
229 120
        $opt = [];
230
231 120
        if ($validatingCarrier !== null) {
232 32
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER);
233
234 32
            $po->carrierInformation = new CarrierInformation($validatingCarrier);
235
236 32
            $opt[] = $po;
237 16
        }
238
239 120
        return $opt;
240
    }
241
242
    /**
243
     * @param string|null $currency
244
     * @return PricePnr13\PricingOptionGroup[]
245
     */
246 120 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...
247
    {
248 120
        $opt = [];
249
250 120
        if ($currency !== null) {
251 32
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE);
252
253 32
            $po->currency = new Currency($currency);
254
255 32
            $opt[] = $po;
256 16
        }
257
258 120
        return $opt;
259
    }
260
261
    /**
262
     * @param FareBasis[] $pricingsFareBasis
263
     * @return PricePnr13\PricingOptionGroup[]
264
     */
265 120 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...
266
    {
267 120
        $opt = [];
268
269 120
        if ($pricingsFareBasis !== null) {
270 120
            foreach ($pricingsFareBasis as $pricingFareBasis) {
271 16
                $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE);
272
273
                //Support for legacy fareBasisPrimaryCode to be removed when breaking BC:
274 16
                $po->optionDetail = new OptionDetail(
275 16
                    $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...
276 8
                );
277
278
                //Support for legacy segmentReference to be removed when breaking BC:
279 16
                $po->paxSegTstReference = new PaxSegTstReference(
280 16
                    $pricingFareBasis->references,
281 16
                    $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...
282 8
                );
283
284 16
                $opt[] = $po;
285 60
            }
286 60
        }
287
288 120
        return $opt;
289
    }
290
291
    /**
292
     * Load corporate negofare
293
     *
294
     * @param string|null $corporateNegoFare
295
     * @return PricingOptionGroup[]
296
     */
297 120
    protected static function loadCorpNegoFare($corporateNegoFare)
298
    {
299 120
        $opt = [];
300
301 120
        if ($corporateNegoFare !== null) {
302 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES);
303
304 4
            $po->optionDetail = new OptionDetail($corporateNegoFare);
305
306 4
            $opt[] = $po;
307 2
        }
308
309 120
        return $opt;
310
    }
311
312
    /**
313
     * Load corporate unifares
314
     *
315
     * @param string[] $corporateUniFares
316
     * @param AwardPricing|null $awardPricing
317
     * @return PricingOptionGroup[]
318
     */
319 120
    protected static function loadCorpUniFares($corporateUniFares, $awardPricing)
320
    {
321 120
        $opt = [];
322
323 120
        if (!empty($corporateUniFares)) {
324 8
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES);
325 8
            $po->optionDetail = new OptionDetail($corporateUniFares);
326 8
            $opt[] = $po;
327
328 8
            if (!empty($awardPricing)) {
329 4
                $opt[] = self::loadAwardPricing($awardPricing);
330 2
            }
331 4
        }
332
333 120
        return $opt;
334
    }
335
336
    /**
337
     * @param AwardPricing $awardPricing
338
     * @return PricingOptionGroup
339
     */
340 4 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...
341
    {
342 4
        $po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING);
343
344 4
        $po->carrierInformation = new CarrierInformation($awardPricing->carrier);
345
346 4
        $po->frequentFlyerInformation = new FrequentFlyerInformation();
347 4
        $po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails(
348 4
            $awardPricing->tierLevel
349 2
        );
350
351 4
        return $po;
352
    }
353
354
    /**
355
     * Load OB Fees
356
     *
357
     * @param ObFee[] $obFees
358
     * @param PaxSegRef[] $obFeeRefs
359
     * @return PricingOptionGroup[]
360
     */
361 120 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...
362
    {
363 120
        $opt = [];
364
365 120
        if (!empty($obFees)) {
366 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES);
367
368 4
            $po->penDisInformation = new PenDisInformation(
369 4
                PenDisInformation::QUAL_OB_FEES,
370 2
                $obFees
371 2
            );
372
373 4
            if (!empty($obFeeRefs)) {
374 4
                $po->paxSegTstReference = new PaxSegTstReference($obFeeRefs);
375 2
            }
376
377 4
            $opt[] = $po;
378 2
        }
379
380 120
        return $opt;
381
    }
382
383
    /**
384
     * @param string[] $paxDiscount
385
     * @param PaxSegRef[] $paxDiscountCodeRefs
386
     * @return PricingOptionGroup[]
387
     */
388 120 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...
389
    {
390 120
        $opt = [];
391
392 120
        if (!empty($paxDiscount)) {
393 16
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC);
394
395 16
            $po->penDisInformation = new PenDisInformation(
396 16
                PenDisInformation::QUAL_DISCOUNT,
397 8
                $paxDiscount
398 8
            );
399
400 16
            if (!empty($paxDiscountCodeRefs)) {
401 16
                $po->paxSegTstReference = new PaxSegTstReference($paxDiscountCodeRefs);
402 8
            }
403
404 16
            $opt[] = $po;
405 8
        }
406
407 120
        return $opt;
408
    }
409
410
    /**
411
     * @param string|null $posOverride
412
     * @param string|null $potOverride
413
     * @return PricingOptionGroup[]
414
     */
415 120 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...
416
    {
417 120
        $opt = [];
418
419 120
        if (!empty($posOverride)) {
420 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE);
421
422 4
            $po->locationInformation = new LocationInformation(
423 4
                LocationInformation::TYPE_POINT_OF_SALE,
424 2
                $posOverride
425 2
            );
426
427 4
            $opt[] = $po;
428 2
        }
429
430 120
        if (!empty($potOverride)) {
431 4
            $po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE);
432
433 4
            $po2->locationInformation = new LocationInformation(
434 4
                LocationInformation::TYPE_POINT_OF_TICKETING,
435 2
                $potOverride
436 2
            );
437
438 4
            $opt[] = $po2;
439 2
        }
440
441 120
        return $opt;
442
    }
443
444
    /**
445
     * @param string|null $pricingLogic
446
     * @return PricingOptionGroup[]
447
     */
448 120 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...
449
    {
450 120
        $opt = [];
451
452 120
        if (!empty($pricingLogic)) {
453 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC);
454 4
            $po->optionDetail = new OptionDetail($pricingLogic);
455 4
            $opt[] = $po;
456 2
        }
457
458 120
        return $opt;
459
    }
460
461
    /**
462
     * @param string|null $ticketType
463
     * @return PricingOptionGroup[]
464
     */
465 120 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...
466
    {
467 120
        $opt = [];
468
469 120
        if (!empty($ticketType)) {
470 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE);
471
472 4
            $po->optionDetail = new OptionDetail($ticketType);
473
474 4
            $opt[] = $po;
475 2
        }
476
477 120
        return $opt;
478
    }
479
480
    /**
481
     * @param Tax[] $taxes
482
     * @return PricingOptionGroup[]
483
     */
484 120 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...
485
    {
486 120
        $opt = [];
487
488 120
        if (!empty($taxes)) {
489 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX);
490
491 4
            foreach ($taxes as $tax) {
492 4
                $qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE;
493 4
                $rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage;
494
495 4
                $po->taxInformation[] = new TaxInformation(
496 4
                    $tax->countryCode,
497 4
                    $tax->taxNature,
498 4
                    $qualifier,
499 2
                    $rate
500 2
                );
501 2
            }
502 4
            $opt[] = $po;
503 2
        }
504
505 120
        return $opt;
506
    }
507
508
    /**
509
     * @param ExemptTax[] $exemptTaxes
510
     * @return PricingOptionGroup[]
511
     */
512 120 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...
513
    {
514 120
        $opt = [];
515
516 120
        if (!empty($exemptTaxes)) {
517 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX);
518
519 4
            foreach ($exemptTaxes as $tax) {
520 4
                $po->taxInformation[] = new TaxInformation(
521 4
                    $tax->countryCode,
522 4
                    $tax->taxNature
523 2
                );
524 2
            }
525
526 4
            $opt[] = $po;
527 2
        }
528
529 120
        return $opt;
530
    }
531
532
    /**
533
     * @param \DateTime|null $pastDate
534
     * @return PricingOptionGroup[]
535
     */
536 120 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...
537
    {
538 120
        $opt = [];
539
540 120
        if ($pastDate instanceof \DateTime) {
541 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING);
542
543 4
            $po->dateInformation = new DateInformation(
544 4
                DateInformation::OPT_DATE_OVERRIDE,
545 2
                $pastDate
546 2
            );
547
548 4
            $opt[] = $po;
549 2
        }
550
551 120
        return $opt;
552
    }
553
554
555
    /**
556
     * @param FormOfPayment[] $formOfPayment
557
     * @return PricingOptionGroup[]
558
     */
559 120
    protected static function loadFormOfPayment($formOfPayment)
560
    {
561 120
        $opt = [];
562
563 120
        if (!empty($formOfPayment)) {
564 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT);
565
566 4
            $po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment);
567
568 4
            $opt[] = $po;
569 2
        }
570
571 120
        return $opt;
572
    }
573
574
    /**
575
     * @param PaxSegRef[] $references
576
     * @return PricingOptionGroup[]
577
     */
578 120
    protected static function loadReferences($references)
579
    {
580 120
        $opt = [];
581
582 120
        if (!empty($references)) {
583 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION);
584
585 4
            $po->paxSegTstReference = new PaxSegTstReference($references);
586
587 4
            $opt[] = $po;
588 2
        }
589
590 120
        return $opt;
591
    }
592
}
593