Completed
Push — master ( d76d99...0fe829 )
by Dieter
07:42
created

loadPricingOptionsFromRequestOptions()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 89
Code Lines 52

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 89
rs 8.5731
c 2
b 0
f 0
cc 2
eloc 52
nc 2
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\ObFee;
30
use Amadeus\Client\RequestOptions\Fare\PricePnr\PaxSegRef;
31
use Amadeus\Client\RequestOptions\Fare\PricePnr\Tax;
32
use Amadeus\Client\RequestOptions\FarePricePnrWithBookingClassOptions;
33
use Amadeus\Client\Struct\BaseWsMessage;
34
use Amadeus\Client\Struct\Fare\PricePnr13\CarrierInformation;
35
use Amadeus\Client\Struct\Fare\PricePnr13\CriteriaDetails;
36
use Amadeus\Client\Struct\Fare\PricePnr13\Currency;
37
use Amadeus\Client\Struct\Fare\PricePnr13\DateInformation;
38
use Amadeus\Client\Struct\Fare\PricePnr13\DiscountPenaltyDetails;
39
use Amadeus\Client\Struct\Fare\PricePnr13\FirstCurrencyDetails;
40
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentFlyerInformation;
41
use Amadeus\Client\Struct\Fare\PricePnr13\FrequentTravellerDetails;
42
use Amadeus\Client\Struct\Fare\PricePnr13\LocationInformation;
43
use Amadeus\Client\Struct\Fare\PricePnr13\OptionDetail;
44
use Amadeus\Client\Struct\Fare\PricePnr13\PaxSegTstReference;
45
use Amadeus\Client\Struct\Fare\PricePnr13\PenDisInformation;
46
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup;
47
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionKey;
48
use Amadeus\Client\Struct\Fare\PricePnr13\TaxData;
49
use Amadeus\Client\Struct\Fare\PricePnr13\TaxInformation;
50
51
/**
52
 * Fare_PricePNRWithBookingClass v 13 and higher structure
53
 *
54
 * @package Amadeus\Client\Struct\Fare
55
 * @author dieter <[email protected]>
56
 */
57
class PricePNRWithBookingClass13 extends BaseWsMessage
58
{
59
    /**
60
     * @var PricePnr13\PricingOptionGroup[]
61
     */
62
    public $pricingOptionGroup = [];
63
64
    /**
65
     * PricePNRWithBookingClass13 constructor.
66
     *
67
     * @param FarePricePnrWithBookingClassOptions $options
68
     * @throws MessageVersionUnsupportedException
69
     */
70
    public function __construct(FarePricePnrWithBookingClassOptions $options)
71
    {
72
        $this->pricingOptionGroup = $this->loadPricingOptionsFromRequestOptions($options);
73
    }
74
75
    /**
76
     * Load an array of PricingOptionGroup objects from the Pricing request options.
77
     *
78
     * Extracted because this method is also used in the InformativePricingWithoutPnr messages.
79
     *
80
     * @param FarePricePnrWithBookingClassOptions $options
81
     * @return PricingOptionGroup[]
82
     */
83
    public static function loadPricingOptionsFromRequestOptions(FarePricePnrWithBookingClassOptions $options)
84
    {
85
        $priceOptions = [];
86
87
        $priceOptions = self::mergeOptions(
88
            $priceOptions,
89
            self::makePricingOptionForValidatingCarrier($options->validatingCarrier)
90
        );
91
92
        $priceOptions = self::mergeOptions(
93
            $priceOptions,
94
            self::makePricingOptionForCurrencyOverride($options->currencyOverride)
95
        );
96
97
        $priceOptions = self::mergeOptions(
98
            $priceOptions,
99
            self::makePricingOptionFareBasisOverride($options->pricingsFareBasis)
100
        );
101
102
        $priceOptions = self::mergeOptions(
103
            $priceOptions,
104
            self::makeOverrideOptions($options->overrideOptions, $priceOptions)
105
        );
106
107
        $priceOptions = self::mergeOptions(
108
            $priceOptions,
109
            self::loadCorpNegoFare($options->corporateNegoFare)
110
        );
111
112
        $priceOptions = self::mergeOptions(
113
            $priceOptions,
114
            self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing)
115
        );
116
117
        $priceOptions = self::mergeOptions(
118
            $priceOptions,
119
            self::loadObFees($options->obFees, $options->obFeeRefs)
120
        );
121
122
        $priceOptions = self::mergeOptions(
123
            $priceOptions,
124
            self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs)
125
        );
126
127
        $priceOptions = self::mergeOptions(
128
            $priceOptions,
129
            self::loadPointOverrides(
130
                $options->pointOfSaleOverride,
131
                $options->pointOfTicketingOverride
132
            )
133
        );
134
135
        $priceOptions = self::mergeOptions(
136
            $priceOptions,
137
            self::loadPricingLogic($options->pricingLogic)
138
        );
139
140
        $priceOptions = self::mergeOptions(
141
            $priceOptions,
142
            self::loadTicketType($options->ticketType)
143
        );
144
145
        $priceOptions = self::mergeOptions(
146
            $priceOptions,
147
            self::loadTaxes($options->taxes)
148
        );
149
150
        $priceOptions = self::mergeOptions(
151
            $priceOptions,
152
            self::loadExemptTaxes($options->exemptTaxes)
153
        );
154
155
        $priceOptions = self::mergeOptions(
156
            $priceOptions,
157
            self::loadPastDate($options->pastDatePricing)
158
        );
159
160
        $priceOptions = self::mergeOptions(
161
            $priceOptions,
162
            self::loadReferences($options->references)
163
        );
164
165
        // All options processed, no options found:
166
        if (empty($priceOptions)) {
167
            $priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
168
        }
169
170
        return $priceOptions;
171
    }
172
173
    /**
174
     * @param string[] $overrideOptions
175
     * @param PricingOptionGroup[] $priceOptions
176
     * @return PricingOptionGroup[]
177
     */
178
    protected static function makeOverrideOptions($overrideOptions, $priceOptions)
179
    {
180
        $opt = [];
181
182
        if (!empty($overrideOptions)) {
183
            foreach ($overrideOptions as $overrideOption) {
184
                if (!self::hasPricingGroup($overrideOption, $priceOptions)) {
185
                    $opt[] = new PricingOptionGroup($overrideOption);
186
                }
187
            }
188
        }
189
190
        return $opt;
191
    }
192
193
    /**
194
     * @param string|null $validatingCarrier
195
     * @return PricePnr13\PricingOptionGroup[]
196
     */
197
    protected static function makePricingOptionForValidatingCarrier($validatingCarrier)
198
    {
199
        $opt = [];
200
201
        if ($validatingCarrier !== null) {
202
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_VALIDATING_CARRIER);
203
204
            $po->carrierInformation = new CarrierInformation($validatingCarrier);
205
206
            $opt[] = $po;
207
        }
208
209
        return $opt;
210
    }
211
212
    /**
213
     * @param string|null $currency
214
     * @return PricePnr13\PricingOptionGroup[]
215
     */
216
    protected static function makePricingOptionForCurrencyOverride($currency)
217
    {
218
        $opt = [];
219
220
        if ($currency !== null) {
221
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_CURRENCY_OVERRIDE);
222
223
            $po->currency = new Currency($currency, FirstCurrencyDetails::QUAL_CURRENCY_OVERRIDE);
224
225
            $opt[] = $po;
226
        }
227
228
        return $opt;
229
    }
230
231
    /**
232
     * @param FareBasis[] $pricingsFareBasis
233
     * @return PricePnr13\PricingOptionGroup[]
234
     */
235
    protected static function makePricingOptionFareBasisOverride($pricingsFareBasis)
236
    {
237
        $opt = [];
238
239
        if ($pricingsFareBasis !== null) {
240
            foreach ($pricingsFareBasis as $pricingFareBasis) {
241
                $po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_BASIS_SIMPLE_OVERRIDE);
242
243
                $po->optionDetail = new OptionDetail();
244
245
                //Support for legacy fareBasisPrimaryCode to be removed when breaking BC:
246
                $po->optionDetail->criteriaDetails[] = new CriteriaDetails(
247
                    $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...
248
                );
249
250
                //Support for legacy segmentReference to be removed when breaking BC:
251
                $po->paxSegTstReference = new PaxSegTstReference(
252
                    $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...
253
                    $pricingFareBasis->references
254
                );
255
256
                $opt[] = $po;
257
            }
258
        }
259
260
        return $opt;
261
    }
262
263
    /**
264
     * Load corporate negofare
265
     *
266
     * @param string|null $corporateNegoFare
267
     * @return PricingOptionGroup[]
268
     */
269 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...
270
    {
271
        $opt = [];
272
273
        if ($corporateNegoFare !== null) {
274
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES);
275
276
            $po->optionDetail = new OptionDetail();
277
            $po->optionDetail->criteriaDetails[] = new CriteriaDetails($corporateNegoFare);
278
279
            $opt[] = $po;
280
        }
281
282
        return $opt;
283
    }
284
285
    /**
286
     * Load corporate unifares
287
     *
288
     * @param string[] $corporateUniFares
289
     * @param AwardPricing|null $awardPricing
290
     * @return PricingOptionGroup[]
291
     */
292
    protected static function loadCorpUniFares($corporateUniFares, $awardPricing)
293
    {
294
        $opt = [];
295
296
        if (!empty($corporateUniFares)) {
297
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_UNIFARES);
298
299
            $po->optionDetail = new OptionDetail();
300
301
            foreach ($corporateUniFares as $corporateUniFare) {
302
                $po->optionDetail->criteriaDetails[] = new CriteriaDetails($corporateUniFare);
303
            }
304
305
            $opt[] = $po;
306
307
            if (!empty($awardPricing)) {
308
                $opt[] = self::loadAwardPricing($awardPricing);
309
            }
310
        }
311
312
        return $opt;
313
    }
314
315
    /**
316
     * @param AwardPricing $awardPricing
317
     * @return PricingOptionGroup
318
     */
319
    protected static function loadAwardPricing($awardPricing)
320
    {
321
        $po = new PricingOptionGroup(PricingOptionKey::OPTION_AWARD_PRICING);
322
323
        $po->optionDetail = new OptionDetail();
324
325
        $po->carrierInformation = new CarrierInformation($awardPricing->carrier);
326
327
        $po->frequentFlyerInformation = new FrequentFlyerInformation();
328
        $po->frequentFlyerInformation->frequentTravellerDetails[] = new FrequentTravellerDetails(
329
            $awardPricing->tierLevel
330
        );
331
332
        return $po;
333
    }
334
335
    /**
336
     * Load OB Fees
337
     *
338
     * @param ObFee[] $obFees
339
     * @param PaxSegRef[] $obFeeRefs
340
     * @return PricingOptionGroup[]
341
     */
342
    protected static function loadObFees($obFees, $obFeeRefs)
343
    {
344
        $opt = [];
345
346
        if (!empty($obFees)) {
347
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES);
348
349
            $po->penDisInformation = new PenDisInformation(PenDisInformation::QUAL_OB_FEES);
350
351
            foreach ($obFees as $obFee) {
352
                $amountType = (!empty($obFee->amount)) ?
353
                    DiscountPenaltyDetails::AMOUNTTYPE_FIXED_WHOLE_AMOUNT :
354
                    DiscountPenaltyDetails::AMOUNTTYPE_PERCENTAGE;
355
356
                $rate = (!empty($obFee->amount)) ? $obFee->amount : $obFee->percentage;
357
358
                $po->penDisInformation->discountPenaltyDetails[] = new DiscountPenaltyDetails(
359
                    $obFee->rate,
360
                    self::makeObFeeFunction($obFee->include),
361
                    $amountType,
362
                    $rate,
363
                    $obFee->currency
364
                );
365
            }
366
367
            if (!empty($obFeeRefs)) {
368
                $po->paxSegTstReference = new PaxSegTstReference(null, $obFeeRefs);
369
            }
370
371
            $opt[] = $po;
372
        }
373
374
        return $opt;
375
    }
376
377
    /**
378
     * @param string[] $paxDiscount
379
     * @param PaxSegRef[] $paxDiscountCodeRefs
380
     * @return PricingOptionGroup[]
381
     */
382
    protected static function loadPaxDiscount($paxDiscount, $paxDiscountCodeRefs)
383
    {
384
        $opt = [];
385
386
        if (!empty($paxDiscount)) {
387
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PASSENGER_DISCOUNT_PTC);
388
389
            $po->penDisInformation = new PenDisInformation(PenDisInformation::QUAL_DISCOUNT);
390
391
            foreach ($paxDiscount as $discount) {
392
                $po->penDisInformation->discountPenaltyDetails[] = new DiscountPenaltyDetails($discount);
393
            }
394
395
            if (!empty($paxDiscountCodeRefs)) {
396
                $po->paxSegTstReference = new PaxSegTstReference(null, $paxDiscountCodeRefs);
397
            }
398
399
            $opt[] = $po;
400
        }
401
402
        return $opt;
403
    }
404
405
    /**
406
     * @param string|null $posOverride
407
     * @param string|null $potOverride
408
     * @return PricingOptionGroup[]
409
     */
410
    protected static function loadPointOverrides($posOverride, $potOverride)
411
    {
412
        $opt = [];
413
414 View Code Duplication
        if (!empty($posOverride)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
415
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_SALE_OVERRIDE);
416
417
            $po->locationInformation = new LocationInformation(
418
                LocationInformation::TYPE_POINT_OF_SALE,
419
                $posOverride
420
            );
421
422
            $opt[] = $po;
423
        }
424
425 View Code Duplication
        if (!empty($potOverride)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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
            $po2 = new PricingOptionGroup(PricingOptionKey::OPTION_POINT_OF_TICKETING_OVERRIDE);
427
428
            $po2->locationInformation = new LocationInformation(
429
                LocationInformation::TYPE_POINT_OF_TICKETING,
430
                $potOverride
431
            );
432
433
            $opt[] = $po2;
434
        }
435
436
        return $opt;
437
    }
438
439
    /**
440
     * @param string|null $pricingLogic
441
     * @return PricingOptionGroup[]
442
     */
443 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...
444
    {
445
        $opt = [];
446
447
        if (!empty($pricingLogic)) {
448
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PRICING_LOGIC);
449
450
            $po->optionDetail = new OptionDetail();
451
            $po->optionDetail->criteriaDetails[] = new CriteriaDetails($pricingLogic);
452
            $opt[] = $po;
453
        }
454
455
        return $opt;
456
    }
457
458
    /**
459
     * @param string|null $ticketType
460
     * @return PricingOptionGroup[]
461
     */
462 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...
463
    {
464
        $opt = [];
465
466
        if (!empty($ticketType)) {
467
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_TICKET_TYPE);
468
469
            $po->optionDetail = new OptionDetail();
470
            $po->optionDetail->criteriaDetails[] = new CriteriaDetails($ticketType);
471
472
            $opt[] = $po;
473
        }
474
475
        return $opt;
476
    }
477
478
    /**
479
     * @param Tax[] $taxes
480
     * @return PricingOptionGroup[]
481
     */
482
    protected static function loadTaxes($taxes)
483
    {
484
        $opt = [];
485
486
        if (!empty($taxes)) {
487
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_ADD_TAX);
488
489
            foreach ($taxes as $tax) {
490
                $qualifier = (!empty($tax->amount)) ? TaxData::QUALIFIER_AMOUNT : TaxData::QUALIFIER_PERCENTAGE;
491
                $rate = (!empty($tax->amount)) ? $tax->amount : $tax->percentage;
492
493
                $po->taxInformation[] = new TaxInformation(
494
                    $tax->countryCode,
495
                    $tax->taxNature,
496
                    $qualifier,
497
                    $rate
498
                );
499
            }
500
            $opt[] = $po;
501
        }
502
503
        return $opt;
504
    }
505
506
    /**
507
     * @param ExemptTax[] $exemptTaxes
508
     * @return PricingOptionGroup[]
509
     */
510 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...
511
    {
512
        $opt = [];
513
514
        if (!empty($exemptTaxes)) {
515
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_EXEMPT_FROM_TAX);
516
517
            foreach ($exemptTaxes as $tax) {
518
                $po->taxInformation[] = new TaxInformation(
519
                    $tax->countryCode,
520
                    $tax->taxNature
521
                );
522
            }
523
524
            $opt[] = $po;
525
        }
526
527
        return $opt;
528
    }
529
530
    /**
531
     * @param \DateTime|null $pastDate
532
     * @return PricingOptionGroup[]
533
     */
534
    protected static function loadPastDate($pastDate)
535
    {
536
        $opt = [];
537
538
        if ($pastDate instanceof \DateTime) {
539
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAST_DATE_PRICING);
540
541
            $po->dateInformation = new DateInformation(
542
                DateInformation::OPT_DATE_OVERRIDE,
543
                $pastDate
544
            );
545
546
            $opt[] = $po;
547
        }
548
549
        return $opt;
550
    }
551
552
    /**
553
     * @param PaxSegRef[] $references
554
     * @return PricingOptionGroup[]
555
     */
556
    protected static function loadReferences($references)
557
    {
558
        $opt = [];
559
560 View Code Duplication
        if (!empty($references)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
561
            $po = new PricingOptionGroup(PricingOptionKey::OPTION_PAX_SEGMENT_TST_SELECTION);
562
563
            $po->paxSegTstReference = new PaxSegTstReference(null, $references);
564
565
            $opt[] = $po;
566
        }
567
568
        return $opt;
569
    }
570
571
    /**
572
     * Make the correct function code
573
     *
574
     * @param bool $include
575
     * @return string
576
     */
577
    protected static function makeObFeeFunction($include)
578
    {
579
        return ($include === true) ? ObFee::FUNCTION_INCLUDE : ObFee::FUNCTION_EXCLUDE;
580
    }
581
582
583
584
    /**
585
     * Avoid double pricing groups when combining an explicitly provided override option with a specific parameter
586
     * that uses the same override option.
587
     *
588
     * Backwards compatibility with PricePnrWithBookingClass12
589
     *
590
     * @param string $optionKey
591
     * @param PricingOptionGroup[] $priceOptions
592
     * @return bool
593
     */
594
    protected static function hasPricingGroup($optionKey, $priceOptions)
595
    {
596
        $found = false;
597
598
        foreach ($priceOptions as $pog) {
599
            if ($pog->pricingOptionKey->pricingOptionKey === $optionKey) {
600
                $found = true;
601
            }
602
        }
603
604
        return $found;
605
    }
606
607
    /**
608
     * Merges Pricing options
609
     *
610
     * @param PricingOptionGroup[] $existingOptions
611
     * @param PricingOptionGroup[] $newOptions
612
     * @return PricingOptionGroup[] merged array
613
     */
614
    protected static function mergeOptions($existingOptions, $newOptions)
615
    {
616
        if (!empty($newOptions)) {
617
            $existingOptions = array_merge(
618
                $existingOptions,
619
                $newOptions
620
            );
621
        }
622
623
        return $existingOptions;
624
    }
625
}
626