Completed
Push — master ( 7cadef...c5dc47 )
by Dieter
07:06
created

makePricingOptionFareFamilyOverride()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 13
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * amadeus-ws-client
4
 *
5
 * Copyright 2015 Amadeus Benelux NV
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 * http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 *
19
 * @package Amadeus
20
 * @license https://opensource.org/licenses/Apache-2.0 Apache 2.0
21
 */
22
23
namespace Amadeus\Client\Struct\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 96
    public function __construct($options)
72
    {
73 96
        if (!is_null($options)) {
74 96
            $this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options);
75 48
        }
76 96
    }
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 124
    public static function loadPricingOptionsFromRequestOptions($options)
87
    {
88 124
        $priceOptions = [];
89
90 124
        $priceOptions = self::mergeOptions(
91 124
            $priceOptions,
92 124
            self::makePricingOptionForValidatingCarrier($options->validatingCarrier)
93 62
        );
94
95 124
        $priceOptions = self::mergeOptions(
96 124
            $priceOptions,
97 124
            self::makePricingOptionForCurrencyOverride($options->currencyOverride)
98 62
        );
99
100 124
        $priceOptions = self::mergeOptions(
101 124
            $priceOptions,
102 124
            self::makePricingOptionFareBasisOverride($options->pricingsFareBasis)
103 62
        );
104
105 124
        $priceOptions = self::mergeOptions(
106 124
            $priceOptions,
107 124
            self::makePricingOptionFareFamilyOverride($options->fareFamily)
108 62
        );
109
110 124
        $priceOptions = self::mergeOptions(
111 124
            $priceOptions,
112 124
            self::loadCorpNegoFare($options->corporateNegoFare)
113 62
        );
114
115 124
        $priceOptions = self::mergeOptions(
116 124
            $priceOptions,
117 124
            self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing)
118 62
        );
119
120 124
        $priceOptions = self::mergeOptions(
121 124
            $priceOptions,
122 124
            self::loadObFees($options->obFees, $options->obFeeRefs)
123 62
        );
124
125 124
        $priceOptions = self::mergeOptions(
126 124
            $priceOptions,
127 124
            self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs)
128 62
        );
129
130 124
        $priceOptions = self::mergeOptions(
131 124
            $priceOptions,
132 124
            self::loadPointOverrides(
133 124
                $options->pointOfSaleOverride,
134 124
                $options->pointOfTicketingOverride
135 62
            )
136 62
        );
137
138 124
        $priceOptions = self::mergeOptions(
139 124
            $priceOptions,
140 124
            self::loadPricingLogic($options->pricingLogic)
141 62
        );
142
143 124
        $priceOptions = self::mergeOptions(
144 124
            $priceOptions,
145 124
            self::loadTicketType($options->ticketType)
146 62
        );
147
148 124
        $priceOptions = self::mergeOptions(
149 124
            $priceOptions,
150 124
            self::loadTaxes($options->taxes)
151 62
        );
152
153 124
        $priceOptions = self::mergeOptions(
154 124
            $priceOptions,
155 124
            self::loadExemptTaxes($options->exemptTaxes)
156 62
        );
157
158 124
        $priceOptions = self::mergeOptions(
159 124
            $priceOptions,
160 124
            self::loadPastDate($options->pastDatePricing)
161 62
        );
162
163
164 124
        $priceOptions = self::mergeOptions(
165 124
            $priceOptions,
166 124
            self::loadFormOfPayment($options->formOfPayment)
167 62
        );
168
169 124
        $priceOptions = self::mergeOptions(
170 124
            $priceOptions,
171 124
            self::loadReferences($options->references)
172 62
        );
173
174 124
        $priceOptions = self::mergeOptions(
175 124
            $priceOptions,
176 124
            self::makeOverrideOptions($options->overrideOptions, $priceOptions)
177 62
        );
178
179 124
        $priceOptions = self::mergeOptions(
180 124
            $priceOptions,
181 124
            self::makeOverrideOptionsWithCriteria($options->overrideOptionsWithCriteria, $priceOptions)
182 62
        );
183
184
        // All options processed, no options found:
185 124
        if (empty($priceOptions)) {
186 24
            $priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
187 12
        }
188
189 124
        return $priceOptions;
190
    }
191
192
    /**
193
     * @param string[] $overrideOptions
194
     * @param PricingOptionGroup[] $priceOptions
195
     * @return PricingOptionGroup[]
196
     */
197 124 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...
198
    {
199 124
        $opt = [];
200
201 124
        foreach ($overrideOptions as $overrideOption) {
202 32
            if (!self::hasPricingGroup($overrideOption, $priceOptions)) {
203 32
                $opt[] = new PricingOptionGroup($overrideOption);
204 16
            }
205 62
        }
206
207 124
        return $opt;
208
    }
209
210
    /**
211
     * @param string[] $overrideOptionsWithCriteria
212
     * @param PricingOptionGroup[] $priceOptions
213
     * @return PricingOptionGroup[]
214
     */
215 124
    protected static function makeOverrideOptionsWithCriteria($overrideOptionsWithCriteria, $priceOptions)
216
    {
217 124
        $opt = [];
218
219 124
        foreach ($overrideOptionsWithCriteria as $overrideOptionWithCriteria) {
220 4
            if (!self::hasPricingGroup($overrideOptionWithCriteria["key"], $priceOptions)) {
221 4
                $opt[] = new PricingOptionGroup($overrideOptionWithCriteria["key"], $overrideOptionWithCriteria["optionDetail"]);
222 2
            }
223 62
        }
224
225 124
        return $opt;
226
    }
227
228
    /**
229
     * @param string|null $validatingCarrier
230
     * @return PricePnr13\PricingOptionGroup[]
231
     */
232 124 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...
233
    {
234 124
        $opt = [];
235
236 124
        if ($validatingCarrier !== null) {
237 32
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER);
238
239 32
            $po->carrierInformation = new CarrierInformation($validatingCarrier);
240
241 32
            $opt[] = $po;
242 16
        }
243
244 124
        return $opt;
245
    }
246
247
    /**
248
     * @param string|null $currency
249
     * @return PricePnr13\PricingOptionGroup[]
250
     */
251 124 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...
252
    {
253 124
        $opt = [];
254
255 124
        if ($currency !== null) {
256 32
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE);
257
258 32
            $po->currency = new Currency($currency);
259
260 32
            $opt[] = $po;
261 16
        }
262
263 124
        return $opt;
264
    }
265
266
    /**
267
     * @param FareBasis[] $pricingsFareBasis
268
     * @return PricePnr13\PricingOptionGroup[]
269
     */
270 124 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...
271
    {
272 124
        $opt = [];
273
274 124
        if ($pricingsFareBasis !== null) {
275 124
            foreach ($pricingsFareBasis as $pricingFareBasis) {
276 16
                $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE);
277
278
                //Support for legacy fareBasisPrimaryCode to be removed when breaking BC:
279 16
                $po->optionDetail = new OptionDetail(
280 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...
281 8
                );
282
283
                //Support for legacy segmentReference to be removed when breaking BC:
284 16
                $po->paxSegTstReference = new PaxSegTstReference(
285 16
                    $pricingFareBasis->references,
286 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...
287 8
                );
288
289 16
                $opt[] = $po;
290 62
            }
291 62
        }
292
293 124
        return $opt;
294
    }
295
296
    /**
297
     * Load fare-family pricing option and return it.
298
     *
299
     * @param string $fareFamily input fare-family, e.g. "CLASSIC"
300
     * @return PricePnr13\PricingOptionGroup[]
301
     */
302 124 View Code Duplication
    protected static function makePricingOptionFareFamilyOverride($fareFamily)
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...
303
    {
304 124
        $opt = [];
305
306 124
        if ($fareFamily !== null) {
307 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_FAMILY);
308 4
            $po->optionDetail = new OptionDetail([['FF' => $fareFamily]]);
309
310 4
            $opt[] = $po;
311 2
        }
312
313 124
        return $opt;
314
    }
315
316
    /**
317
     * Load corporate negofare
318
     *
319
     * @param string|null $corporateNegoFare
320
     * @return PricingOptionGroup[]
321
     */
322 124 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...
323
    {
324 124
        $opt = [];
325
326 124
        if ($corporateNegoFare !== null) {
327 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES);
328
329 4
            $po->optionDetail = new OptionDetail($corporateNegoFare);
330
331 4
            $opt[] = $po;
332 2
        }
333
334 124
        return $opt;
335
    }
336
337
    /**
338
     * Load corporate unifares
339
     *
340
     * @param string[] $corporateUniFares
341
     * @param AwardPricing|null $awardPricing
342
     * @return PricingOptionGroup[]
343
     */
344 124
    protected static function loadCorpUniFares($corporateUniFares, $awardPricing)
345
    {
346 124
        $opt = [];
347
348 124
        if (!empty($corporateUniFares)) {
349 8
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES);
350 8
            $po->optionDetail = new OptionDetail($corporateUniFares);
351 8
            $opt[] = $po;
352
353 8
            if (!empty($awardPricing)) {
354 4
                $opt[] = self::loadAwardPricing($awardPricing);
355 2
            }
356 4
        }
357
358 124
        return $opt;
359
    }
360
361
    /**
362
     * @param AwardPricing $awardPricing
363
     * @return PricingOptionGroup
364
     */
365 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...
366
    {
367 4
        $po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING);
368
369 4
        $po->carrierInformation = new CarrierInformation($awardPricing->carrier);
370
371 4
        $po->frequentFlyerInformation = new FrequentFlyerInformation();
372 4
        $po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails(
373 4
            $awardPricing->tierLevel
374 2
        );
375
376 4
        return $po;
377
    }
378
379
    /**
380
     * Load OB Fees
381
     *
382
     * @param ObFee[] $obFees
383
     * @param PaxSegRef[] $obFeeRefs
384
     * @return PricingOptionGroup[]
385
     */
386 124 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...
387
    {
388 124
        $opt = [];
389
390 124
        if (!empty($obFees)) {
391 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES);
392
393 4
            $po->penDisInformation = new PenDisInformation(
394 4
                PenDisInformation::QUAL_OB_FEES,
395 2
                $obFees
396 2
            );
397
398 4
            if (!empty($obFeeRefs)) {
399 4
                $po->paxSegTstReference = new PaxSegTstReference($obFeeRefs);
400 2
            }
401
402 4
            $opt[] = $po;
403 2
        }
404
405 124
        return $opt;
406
    }
407
408
    /**
409
     * @param string[] $paxDiscount
410
     * @param PaxSegRef[] $paxDiscountCodeRefs
411
     * @return PricingOptionGroup[]
412
     */
413 124 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...
414
    {
415 124
        $opt = [];
416
417 124
        if (!empty($paxDiscount)) {
418 16
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC);
419
420 16
            $po->penDisInformation = new PenDisInformation(
421 16
                PenDisInformation::QUAL_DISCOUNT,
422 8
                $paxDiscount
423 8
            );
424
425 16
            if (!empty($paxDiscountCodeRefs)) {
426 16
                $po->paxSegTstReference = new PaxSegTstReference($paxDiscountCodeRefs);
427 8
            }
428
429 16
            $opt[] = $po;
430 8
        }
431
432 124
        return $opt;
433
    }
434
435
    /**
436
     * @param string|null $posOverride
437
     * @param string|null $potOverride
438
     * @return PricingOptionGroup[]
439
     */
440 124 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...
441
    {
442 124
        $opt = [];
443
444 124
        if (!empty($posOverride)) {
445 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE);
446
447 4
            $po->locationInformation = new LocationInformation(
448 4
                LocationInformation::TYPE_POINT_OF_SALE,
449 2
                $posOverride
450 2
            );
451
452 4
            $opt[] = $po;
453 2
        }
454
455 124
        if (!empty($potOverride)) {
456 4
            $po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE);
457
458 4
            $po2->locationInformation = new LocationInformation(
459 4
                LocationInformation::TYPE_POINT_OF_TICKETING,
460 2
                $potOverride
461 2
            );
462
463 4
            $opt[] = $po2;
464 2
        }
465
466 124
        return $opt;
467
    }
468
469
    /**
470
     * @param string|null $pricingLogic
471
     * @return PricingOptionGroup[]
472
     */
473 124 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...
474
    {
475 124
        $opt = [];
476
477 124
        if (!empty($pricingLogic)) {
478 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC);
479 4
            $po->optionDetail = new OptionDetail($pricingLogic);
480 4
            $opt[] = $po;
481 2
        }
482
483 124
        return $opt;
484
    }
485
486
    /**
487
     * @param string|null $ticketType
488
     * @return PricingOptionGroup[]
489
     */
490 124 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...
491
    {
492 124
        $opt = [];
493
494 124
        if (!empty($ticketType)) {
495 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE);
496
497 4
            $po->optionDetail = new OptionDetail($ticketType);
498
499 4
            $opt[] = $po;
500 2
        }
501
502 124
        return $opt;
503
    }
504
505
    /**
506
     * @param Tax[] $taxes
507
     * @return PricingOptionGroup[]
508
     */
509 124 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...
510
    {
511 124
        $opt = [];
512
513 124
        if (!empty($taxes)) {
514 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX);
515
516 4
            foreach ($taxes as $tax) {
517 4
                $qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE;
518 4
                $rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage;
519
520 4
                $po->taxInformation[] = new TaxInformation(
521 4
                    $tax->countryCode,
522 4
                    $tax->taxNature,
523 4
                    $qualifier,
524 2
                    $rate
525 2
                );
526 2
            }
527 4
            $opt[] = $po;
528 2
        }
529
530 124
        return $opt;
531
    }
532
533
    /**
534
     * @param ExemptTax[] $exemptTaxes
535
     * @return PricingOptionGroup[]
536
     */
537 124 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...
538
    {
539 124
        $opt = [];
540
541 124
        if (!empty($exemptTaxes)) {
542 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX);
543
544 4
            foreach ($exemptTaxes as $tax) {
545 4
                $po->taxInformation[] = new TaxInformation(
546 4
                    $tax->countryCode,
547 4
                    $tax->taxNature
548 2
                );
549 2
            }
550
551 4
            $opt[] = $po;
552 2
        }
553
554 124
        return $opt;
555
    }
556
557
    /**
558
     * @param \DateTime|null $pastDate
559
     * @return PricingOptionGroup[]
560
     */
561 124 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...
562
    {
563 124
        $opt = [];
564
565 124
        if ($pastDate instanceof \DateTime) {
566 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING);
567
568 4
            $po->dateInformation = new DateInformation(
569 4
                DateInformation::OPT_DATE_OVERRIDE,
570 2
                $pastDate
571 2
            );
572
573 4
            $opt[] = $po;
574 2
        }
575
576 124
        return $opt;
577
    }
578
579
580
    /**
581
     * @param FormOfPayment[] $formOfPayment
582
     * @return PricingOptionGroup[]
583
     */
584 124
    protected static function loadFormOfPayment($formOfPayment)
585
    {
586 124
        $opt = [];
587
588 124
        if (!empty($formOfPayment)) {
589 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT);
590
591 4
            $po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment);
592
593 4
            $opt[] = $po;
594 2
        }
595
596 124
        return $opt;
597
    }
598
599
    /**
600
     * @param PaxSegRef[] $references
601
     * @return PricingOptionGroup[]
602
     */
603 124
    protected static function loadReferences($references)
604
    {
605 124
        $opt = [];
606
607 124
        if (!empty($references)) {
608 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION);
609
610 4
            $po->paxSegTstReference = new PaxSegTstReference($references);
611
612 4
            $opt[] = $po;
613 2
        }
614
615 124
        return $opt;
616
    }
617
}
618