Completed
Push — master ( 84b838...db89dd )
by Dieter
08:17
created

PricePNRWithBookingClass13   C

Complexity

Total Complexity 47

Size/Duplication

Total Lines 512
Duplicated Lines 56.84 %

Coupling/Cohesion

Components 1
Dependencies 18

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 47
lcom 1
cbo 18
dl 291
loc 512
c 2
b 0
f 0
ccs 259
cts 259
cp 1
rs 5.5079

19 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
B loadPricingOptionsFromRequestOptions() 0 95 2
A makeOverrideOptions() 12 12 3
A makePricingOptionForValidatingCarrier() 14 14 2
A makePricingOptionForCurrencyOverride() 14 14 2
B makePricingOptionFareBasisOverride() 25 25 3
A loadCorpNegoFare() 14 14 2
A loadCorpUniFares() 16 16 3
A loadAwardPricing() 13 13 1
A loadObFees() 21 21 3
A loadPaxDiscount() 21 21 3
B loadPointOverrides() 28 28 3
A loadPricingLogic() 12 12 2
A loadTicketType() 14 14 2
B loadTaxes() 23 23 5
A loadExemptTaxes() 19 19 3
A loadPastDate() 17 17 2
A loadFormOfPayment() 14 14 2
A loadReferences() 14 14 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like PricePNRWithBookingClass13 often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use PricePNRWithBookingClass13, and based on these observations, apply Extract Interface, too.

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 22
    public function __construct($options)
72
    {
73 22
        if (!is_null($options)) {
74 22
            $this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options);
75 22
        }
76 22
    }
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 29
    public static function loadPricingOptionsFromRequestOptions($options)
87
    {
88 29
        $priceOptions = [];
89
90 29
        $priceOptions = self::mergeOptions(
91 29
            $priceOptions,
92 29
            self::makePricingOptionForValidatingCarrier($options->validatingCarrier)
93 29
        );
94
95 29
        $priceOptions = self::mergeOptions(
96 29
            $priceOptions,
97 29
            self::makePricingOptionForCurrencyOverride($options->currencyOverride)
98 29
        );
99
100 29
        $priceOptions = self::mergeOptions(
101 29
            $priceOptions,
102 29
            self::makePricingOptionFareBasisOverride($options->pricingsFareBasis)
103 29
        );
104
105 29
        $priceOptions = self::mergeOptions(
106 29
            $priceOptions,
107 29
            self::loadCorpNegoFare($options->corporateNegoFare)
108 29
        );
109
110 29
        $priceOptions = self::mergeOptions(
111 29
            $priceOptions,
112 29
            self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing)
113 29
        );
114
115 29
        $priceOptions = self::mergeOptions(
116 29
            $priceOptions,
117 29
            self::loadObFees($options->obFees, $options->obFeeRefs)
118 29
        );
119
120 29
        $priceOptions = self::mergeOptions(
121 29
            $priceOptions,
122 29
            self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs)
123 29
        );
124
125 29
        $priceOptions = self::mergeOptions(
126 29
            $priceOptions,
127 29
            self::loadPointOverrides(
128 29
                $options->pointOfSaleOverride,
129 29
                $options->pointOfTicketingOverride
130 29
            )
131 29
        );
132
133 29
        $priceOptions = self::mergeOptions(
134 29
            $priceOptions,
135 29
            self::loadPricingLogic($options->pricingLogic)
136 29
        );
137
138 29
        $priceOptions = self::mergeOptions(
139 29
            $priceOptions,
140 29
            self::loadTicketType($options->ticketType)
141 29
        );
142
143 29
        $priceOptions = self::mergeOptions(
144 29
            $priceOptions,
145 29
            self::loadTaxes($options->taxes)
146 29
        );
147
148 29
        $priceOptions = self::mergeOptions(
149 29
            $priceOptions,
150 29
            self::loadExemptTaxes($options->exemptTaxes)
151 29
        );
152
153 29
        $priceOptions = self::mergeOptions(
154 29
            $priceOptions,
155 29
            self::loadPastDate($options->pastDatePricing)
156 29
        );
157
158
159 29
        $priceOptions = self::mergeOptions(
160 29
            $priceOptions,
161 29
            self::loadFormOfPayment($options->formOfPayment)
162 29
        );
163
164 29
        $priceOptions = self::mergeOptions(
165 29
            $priceOptions,
166 29
            self::loadReferences($options->references)
167 29
        );
168
169 29
        $priceOptions = self::mergeOptions(
170 29
            $priceOptions,
171 29
            self::makeOverrideOptions($options->overrideOptions, $priceOptions)
172 29
        );
173
174
        // All options processed, no options found:
175 29
        if (empty($priceOptions)) {
176 6
            $priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
177 6
        }
178
179 29
        return $priceOptions;
180
    }
181
182
    /**
183
     * @param string[] $overrideOptions
184
     * @param PricingOptionGroup[] $priceOptions
185
     * @return PricingOptionGroup[]
186
     */
187 29 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...
188
    {
189 29
        $opt = [];
190
191 29
        foreach ($overrideOptions as $overrideOption) {
192 8
            if (!self::hasPricingGroup($overrideOption, $priceOptions)) {
193 8
                $opt[] = new PricingOptionGroup($overrideOption);
194 8
            }
195 29
        }
196
197 29
        return $opt;
198
    }
199
200
    /**
201
     * @param string|null $validatingCarrier
202
     * @return PricePnr13\PricingOptionGroup[]
203
     */
204 29 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...
205
    {
206 29
        $opt = [];
207
208 29
        if ($validatingCarrier !== null) {
209 7
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER);
210
211 7
            $po->carrierInformation = new CarrierInformation($validatingCarrier);
212
213 7
            $opt[] = $po;
214 7
        }
215
216 29
        return $opt;
217
    }
218
219
    /**
220
     * @param string|null $currency
221
     * @return PricePnr13\PricingOptionGroup[]
222
     */
223 29 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...
224
    {
225 29
        $opt = [];
226
227 29
        if ($currency !== null) {
228 7
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE);
229
230 7
            $po->currency = new Currency($currency);
231
232 7
            $opt[] = $po;
233 7
        }
234
235 29
        return $opt;
236
    }
237
238
    /**
239
     * @param FareBasis[] $pricingsFareBasis
240
     * @return PricePnr13\PricingOptionGroup[]
241
     */
242 29 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...
243
    {
244 29
        $opt = [];
245
246 29
        if ($pricingsFareBasis !== null) {
247 29
            foreach ($pricingsFareBasis as $pricingFareBasis) {
248 4
                $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE);
249
250
                //Support for legacy fareBasisPrimaryCode to be removed when breaking BC:
251 4
                $po->optionDetail = new OptionDetail(
252 4
                    $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...
253 4
                );
254
255
                //Support for legacy segmentReference to be removed when breaking BC:
256 4
                $po->paxSegTstReference = new PaxSegTstReference(
257 4
                    $pricingFareBasis->references,
258 4
                    $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...
259 4
                );
260
261 4
                $opt[] = $po;
262 29
            }
263 29
        }
264
265 29
        return $opt;
266
    }
267
268
    /**
269
     * Load corporate negofare
270
     *
271
     * @param string|null $corporateNegoFare
272
     * @return PricingOptionGroup[]
273
     */
274 29 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...
275
    {
276 29
        $opt = [];
277
278 29
        if ($corporateNegoFare !== null) {
279 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES);
280
281 1
            $po->optionDetail = new OptionDetail($corporateNegoFare);
282
283 1
            $opt[] = $po;
284 1
        }
285
286 29
        return $opt;
287
    }
288
289
    /**
290
     * Load corporate unifares
291
     *
292
     * @param string[] $corporateUniFares
293
     * @param AwardPricing|null $awardPricing
294
     * @return PricingOptionGroup[]
295
     */
296 29 View Code Duplication
    protected static function loadCorpUniFares($corporateUniFares, $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...
297
    {
298 29
        $opt = [];
299
300 29
        if (!empty($corporateUniFares)) {
301 2
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES);
302 2
            $po->optionDetail = new OptionDetail($corporateUniFares);
303 2
            $opt[] = $po;
304
305 2
            if (!empty($awardPricing)) {
306 1
                $opt[] = self::loadAwardPricing($awardPricing);
307 1
            }
308 2
        }
309
310 29
        return $opt;
311
    }
312
313
    /**
314
     * @param AwardPricing $awardPricing
315
     * @return PricingOptionGroup
316
     */
317 1 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...
318
    {
319 1
        $po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING);
320
321 1
        $po->carrierInformation = new CarrierInformation($awardPricing->carrier);
322
323 1
        $po->frequentFlyerInformation = new FrequentFlyerInformation();
324 1
        $po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails(
325 1
            $awardPricing->tierLevel
326 1
        );
327
328 1
        return $po;
329
    }
330
331
    /**
332
     * Load OB Fees
333
     *
334
     * @param ObFee[] $obFees
335
     * @param PaxSegRef[] $obFeeRefs
336
     * @return PricingOptionGroup[]
337
     */
338 29 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...
339
    {
340 29
        $opt = [];
341
342 29
        if (!empty($obFees)) {
343 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES);
344
345 1
            $po->penDisInformation = new PenDisInformation(
346 1
                PenDisInformation::QUAL_OB_FEES,
347
                $obFees
348 1
            );
349
350 1
            if (!empty($obFeeRefs)) {
351 1
                $po->paxSegTstReference = new PaxSegTstReference($obFeeRefs);
352 1
            }
353
354 1
            $opt[] = $po;
355 1
        }
356
357 29
        return $opt;
358
    }
359
360
    /**
361
     * @param string[] $paxDiscount
362
     * @param PaxSegRef[] $paxDiscountCodeRefs
363
     * @return PricingOptionGroup[]
364
     */
365 29 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...
366
    {
367 29
        $opt = [];
368
369 29
        if (!empty($paxDiscount)) {
370 4
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC);
371
372 4
            $po->penDisInformation = new PenDisInformation(
373 4
                PenDisInformation::QUAL_DISCOUNT,
374
                $paxDiscount
375 4
            );
376
377 4
            if (!empty($paxDiscountCodeRefs)) {
378 4
                $po->paxSegTstReference = new PaxSegTstReference($paxDiscountCodeRefs);
379 4
            }
380
381 4
            $opt[] = $po;
382 4
        }
383
384 29
        return $opt;
385
    }
386
387
    /**
388
     * @param string|null $posOverride
389
     * @param string|null $potOverride
390
     * @return PricingOptionGroup[]
391
     */
392 29 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...
393
    {
394 29
        $opt = [];
395
396 29
        if (!empty($posOverride)) {
397 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE);
398
399 1
            $po->locationInformation = new LocationInformation(
400 1
                LocationInformation::TYPE_POINT_OF_SALE,
401
                $posOverride
402 1
            );
403
404 1
            $opt[] = $po;
405 1
        }
406
407 29
        if (!empty($potOverride)) {
408 1
            $po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE);
409
410 1
            $po2->locationInformation = new LocationInformation(
411 1
                LocationInformation::TYPE_POINT_OF_TICKETING,
412
                $potOverride
413 1
            );
414
415 1
            $opt[] = $po2;
416 1
        }
417
418 29
        return $opt;
419
    }
420
421
    /**
422
     * @param string|null $pricingLogic
423
     * @return PricingOptionGroup[]
424
     */
425 29 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...
426
    {
427 29
        $opt = [];
428
429 29
        if (!empty($pricingLogic)) {
430 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC);
431 1
            $po->optionDetail = new OptionDetail($pricingLogic);
432 1
            $opt[] = $po;
433 1
        }
434
435 29
        return $opt;
436
    }
437
438
    /**
439
     * @param string|null $ticketType
440
     * @return PricingOptionGroup[]
441
     */
442 29 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...
443
    {
444 29
        $opt = [];
445
446 29
        if (!empty($ticketType)) {
447 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE);
448
449 1
            $po->optionDetail = new OptionDetail($ticketType);
450
451 1
            $opt[] = $po;
452 1
        }
453
454 29
        return $opt;
455
    }
456
457
    /**
458
     * @param Tax[] $taxes
459
     * @return PricingOptionGroup[]
460
     */
461 29 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...
462
    {
463 29
        $opt = [];
464
465 29
        if (!empty($taxes)) {
466 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX);
467
468 1
            foreach ($taxes as $tax) {
469 1
                $qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE;
470 1
                $rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage;
471
472 1
                $po->taxInformation[] = new TaxInformation(
473 1
                    $tax->countryCode,
474 1
                    $tax->taxNature,
475 1
                    $qualifier,
476
                    $rate
477 1
                );
478 1
            }
479 1
            $opt[] = $po;
480 1
        }
481
482 29
        return $opt;
483
    }
484
485
    /**
486
     * @param ExemptTax[] $exemptTaxes
487
     * @return PricingOptionGroup[]
488
     */
489 29 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...
490
    {
491 29
        $opt = [];
492
493 29
        if (!empty($exemptTaxes)) {
494 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX);
495
496 1
            foreach ($exemptTaxes as $tax) {
497 1
                $po->taxInformation[] = new TaxInformation(
498 1
                    $tax->countryCode,
499 1
                    $tax->taxNature
500 1
                );
501 1
            }
502
503 1
            $opt[] = $po;
504 1
        }
505
506 29
        return $opt;
507
    }
508
509
    /**
510
     * @param \DateTime|null $pastDate
511
     * @return PricingOptionGroup[]
512
     */
513 29 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...
514
    {
515 29
        $opt = [];
516
517 29
        if ($pastDate instanceof \DateTime) {
518 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING);
519
520 1
            $po->dateInformation = new DateInformation(
521 1
                DateInformation::OPT_DATE_OVERRIDE,
522
                $pastDate
523 1
            );
524
525 1
            $opt[] = $po;
526 1
        }
527
528 29
        return $opt;
529
    }
530
531
532
    /**
533
     * @param FormOfPayment[] $formOfPayment
534
     * @return PricingOptionGroup[]
535
     */
536 29 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...
537
    {
538 29
        $opt = [];
539
540 29
        if (!empty($formOfPayment)) {
541 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FORM_OF_PAYMENT);
542
543 1
            $po->formOfPaymentInformation = new FormOfPaymentInformation($formOfPayment);
544
545 1
            $opt[] = $po;
546 1
        }
547
548 29
        return $opt;
549
    }
550
551
    /**
552
     * @param PaxSegRef[] $references
553
     * @return PricingOptionGroup[]
554
     */
555 29 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...
556
    {
557 29
        $opt = [];
558
559 29
        if (!empty($references)) {
560 1
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION);
561
562 1
            $po->paxSegTstReference = new PaxSegTstReference($references);
563
564 1
            $opt[] = $po;
565 1
        }
566
567 29
        return $opt;
568
    }
569
}
570