Completed
Pull Request — master (#248)
by
unknown
32:06
created

makePricingOptionFareBasisOverride()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 25

Duplication

Lines 25
Ratio 100 %

Code Coverage

Tests 16
CRAP Score 3

Importance

Changes 0
Metric Value
dl 25
loc 25
ccs 16
cts 16
cp 1
rs 9.52
c 0
b 0
f 0
cc 3
nc 2
nop 1
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\Cabin;
28
use Amadeus\Client\RequestOptions\Fare\PricePnr\ExemptTax;
29
use Amadeus\Client\RequestOptions\Fare\PricePnr\FareBasis;
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\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 92
    public function __construct($options)
73
    {
74 92
        if (!is_null($options)) {
75 92
            $this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options);
76 46
        }
77 92
    }
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 120
    public static function loadPricingOptionsFromRequestOptions($options)
88
    {
89 120
        $priceOptions = [];
90
91 120
        $priceOptions = self::mergeOptions(
92 120
            $priceOptions,
93 120
            self::makePricingOptionForValidatingCarrier($options->validatingCarrier)
94 60
        );
95
96 120
        $priceOptions = self::mergeOptions(
97 120
            $priceOptions,
98 120
            self::makePricingOptionForCurrencyOverride($options->currencyOverride)
99 60
        );
100
101 120
        $priceOptions = self::mergeOptions(
102 120
            $priceOptions,
103 120
            self::makePricingOptionFareBasisOverride($options->pricingsFareBasis)
104 60
        );
105
106 120
        $priceOptions = self::mergeOptions(
107 120
            $priceOptions,
108 120
            self::loadCorpNegoFare($options->corporateNegoFare)
109 60
        );
110
111 120
        $priceOptions = self::mergeOptions(
112 120
            $priceOptions,
113 120
            self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing)
114 60
        );
115
116 120
        $priceOptions = self::mergeOptions(
117 120
            $priceOptions,
118 120
            self::loadObFees($options->obFees, $options->obFeeRefs)
119 60
        );
120
121 120
        $priceOptions = self::mergeOptions(
122 120
            $priceOptions,
123 120
            self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs)
124 60
        );
125
126 120
        $priceOptions = self::mergeOptions(
127 120
            $priceOptions,
128 120
            self::loadPointOverrides(
129 120
                $options->pointOfSaleOverride,
130 120
                $options->pointOfTicketingOverride
131 60
            )
132 60
        );
133
134 120
        $priceOptions = self::mergeOptions(
135 120
            $priceOptions,
136 120
            self::loadPricingLogic($options->pricingLogic)
137 60
        );
138
139 120
        $priceOptions = self::mergeOptions(
140 120
            $priceOptions,
141 120
            self::loadTicketType($options->ticketType)
142 60
        );
143
144 120
        $priceOptions = self::mergeOptions(
145 120
            $priceOptions,
146 120
            self::loadTaxes($options->taxes)
147 60
        );
148
149 120
        $priceOptions = self::mergeOptions(
150 120
            $priceOptions,
151 120
            self::loadExemptTaxes($options->exemptTaxes)
152 60
        );
153
154 120
        $priceOptions = self::mergeOptions(
155 120
            $priceOptions,
156 120
            self::loadPastDate($options->pastDatePricing)
157 60
        );
158
159
160 120
        $priceOptions = self::mergeOptions(
161 120
            $priceOptions,
162 120
            self::loadFormOfPayment($options->formOfPayment)
163 60
        );
164
165 120
        $priceOptions = self::mergeOptions(
166 120
            $priceOptions,
167 120
            self::loadReferences($options->references)
168 60
        );
169
170 120
        $priceOptions = self::mergeOptions(
171 120
            $priceOptions,
172 120
            self::makeOverrideOptions($options->overrideOptions, $priceOptions)
173 60
        );
174
175 120
        $priceOptions = self::mergeOptions(
176 120
            $priceOptions,
177 120
            self::makeOverrideOptionsWithCriteria($options->overrideOptionsWithCriteria, $priceOptions)
178 60
        );
179
180 120
        $priceOptions = self::mergeOptions(
181 120
            $priceOptions,
182 120
            self::loadCabin($options->cabin)
183 60
        );
184
185
        // All options processed, no options found:
186 120
        if (empty($priceOptions)) {
187 24
            $priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
188 12
        }
189
190 120
        return $priceOptions;
191
    }
192
193
    /**
194
     * @param string[] $overrideOptions
195
     * @param PricingOptionGroup[] $priceOptions
196
     * @return PricingOptionGroup[]
197
     */
198 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...
199
    {
200 120
        $opt = [];
201
202 120
        foreach ($overrideOptions as $overrideOption) {
203 32
            if (!self::hasPricingGroup($overrideOption, $priceOptions)) {
204 32
                $opt[] = new PricingOptionGroup($overrideOption);
205 16
            }
206 60
        }
207
208 120
        return $opt;
209
    }
210
211
    /**
212
     * @param string[] $overrideOptionsWithCriteria
213
     * @param PricingOptionGroup[] $priceOptions
214
     * @return PricingOptionGroup[]
215
     */
216 120
    protected static function makeOverrideOptionsWithCriteria($overrideOptionsWithCriteria, $priceOptions)
217
    {
218 120
        $opt = [];
219
220 120
        foreach ($overrideOptionsWithCriteria as $overrideOptionWithCriteria) {
221 4
            if (!self::hasPricingGroup($overrideOptionWithCriteria["key"], $priceOptions)) {
222 4
                $opt[] = new PricingOptionGroup($overrideOptionWithCriteria["key"], $overrideOptionWithCriteria["optionDetail"]);
223 2
            }
224 60
        }
225
226 120
        return $opt;
227
    }
228
229
    /**
230
     * @param string|null $validatingCarrier
231
     * @return PricePnr13\PricingOptionGroup[]
232
     */
233 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...
234
    {
235 120
        $opt = [];
236
237 120
        if ($validatingCarrier !== null) {
238 32
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER);
239
240 32
            $po->carrierInformation = new CarrierInformation($validatingCarrier);
241
242 32
            $opt[] = $po;
243 16
        }
244
245 120
        return $opt;
246
    }
247
248
    /**
249
     * @param string|null $currency
250
     * @return PricePnr13\PricingOptionGroup[]
251
     */
252 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...
253
    {
254 120
        $opt = [];
255
256 120
        if ($currency !== null) {
257 32
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE);
258
259 32
            $po->currency = new Currency($currency);
260
261 32
            $opt[] = $po;
262 16
        }
263
264 120
        return $opt;
265
    }
266
267
    /**
268
     * @param Cabin $cabin
269
     * @return PricePnr13\PricingOptionGroup[]
270
     */
271 120
    protected static function loadCabin($cabin)
272
    {
273 120
        $opt = [];
274
275 120
        if ($cabin instanceof Cabin) {
276 4
            $opt[] = new PricingOptionGroup(PricingOptionKey::OPTION_CABIN, $cabin->criteriaDetails);
0 ignored issues
show
Documentation introduced by
$cabin->criteriaDetails is of type array, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

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