1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* amadeus-ws-client |
4
|
|
|
* |
5
|
|
|
* Copyright 2020 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\RequestOptions\FarePriceUpsellWithoutPnrOptions; |
26
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
27
|
|
|
use Amadeus\Client\Struct\Fare\InformativePricing13\PassengersGroup; |
28
|
|
|
use Amadeus\Client\Struct\Fare\InformativePricing13\SegmentGroup; |
29
|
|
|
use Amadeus\Client\Struct\Fare\PricePnr13\PricingOptionGroup; |
30
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Passenger; |
31
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Segment; |
32
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* PriceUpsellWithoutPNR |
36
|
|
|
* |
37
|
|
|
* @package Amadeus\Client\Struct\Fare |
38
|
|
|
* @author Valerii Nezhurov <[email protected]> |
39
|
|
|
*/ |
40
|
|
View Code Duplication |
class PriceUpsellWithoutPNR extends BaseWsMessage |
|
|
|
|
41
|
|
|
{ |
42
|
|
|
/** |
43
|
|
|
* @var PassengersGroup[] |
44
|
|
|
*/ |
45
|
|
|
public $passengersGroup = []; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var SegmentGroup[] |
49
|
|
|
*/ |
50
|
|
|
public $segmentGroup = []; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @var PricingOptionGroup[] |
54
|
|
|
*/ |
55
|
|
|
public $pricingOptionGroup = []; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* PriceUpsellWithoutPNR constructor. |
59
|
|
|
* |
60
|
|
|
* @param FarePriceUpsellWithoutPnrOptions|null $options |
61
|
|
|
*/ |
62
|
|
|
public function __construct($options) |
63
|
|
|
{ |
64
|
|
|
if ($options === null) { |
65
|
|
|
return; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$this->loadPassengers($options->passengers); |
69
|
|
|
$this->loadSegments($options->segments); |
70
|
|
|
$this->loadPricingOptions($options->pricingOptions); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @param Passenger[] $passengers |
75
|
|
|
*/ |
76
|
|
|
protected function loadPassengers($passengers) |
77
|
|
|
{ |
78
|
|
|
$counter = 1; |
79
|
|
|
|
80
|
|
|
foreach ($passengers as $passenger) { |
81
|
|
|
$this->passengersGroup[] = new PassengersGroup($passenger, $counter); |
82
|
|
|
$counter++; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param Segment[] $segments |
88
|
|
|
*/ |
89
|
|
|
protected function loadSegments($segments) |
90
|
|
|
{ |
91
|
|
|
foreach ($segments as $segment) { |
92
|
|
|
$this->segmentGroup[] = new SegmentGroup($segment); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param PricingOptions|null $pricingOptions |
98
|
|
|
*/ |
99
|
|
|
protected function loadPricingOptions($pricingOptions) |
100
|
|
|
{ |
101
|
|
|
if (!($pricingOptions instanceof PricingOptions)) { |
102
|
|
|
$pricingOptions = new PricingOptions(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$this->pricingOptionGroup = PricePNRWithBookingClass13::loadPricingOptionsFromRequestOptions($pricingOptions); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
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.