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
|
|
|
namespace Amadeus\Client\Struct\Service; |
23
|
|
|
|
24
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Passenger; |
25
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\PricingOptions; |
26
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Segment; |
27
|
|
|
use Amadeus\Client\RequestOptions\ServiceStandaloneCatalogueOptions; |
28
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
29
|
|
|
use Amadeus\Client\Struct\Service\StandaloneCatalogue\PassengerInfoGroup; |
30
|
|
|
use Amadeus\Client\Struct\Service\StandaloneCatalogue\FlightInfo; |
31
|
|
|
use Amadeus\Client\Struct\Fare\PricePNRWithBookingClass13; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* StandaloneCatalogue |
35
|
|
|
* |
36
|
|
|
* @package Amadeus\Client\Struct\Fare |
37
|
|
|
* @author Arvind Pandey <[email protected]> |
38
|
|
|
*/ |
39
|
|
|
class StandaloneCatalogue extends BaseWsMessage |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @var PassengerInfoGroup[] |
45
|
|
|
*/ |
46
|
|
|
public $passengerInfoGroup = []; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* |
50
|
|
|
* @var FlightInfo[] |
51
|
|
|
*/ |
52
|
|
|
public $flightInfo = []; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
* @var PricingOptions[] |
57
|
|
|
*/ |
58
|
|
|
public $pricingOption = []; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* StandaloneCatalogue constructor. |
62
|
|
|
* |
63
|
|
|
* @param ServiceStandaloneCatalogueOptions|null $options |
64
|
|
|
*/ |
65
|
|
View Code Duplication |
public function __construct($options) |
|
|
|
|
66
|
|
|
{ |
67
|
|
|
if (! is_null($options)) { |
68
|
|
|
$this->loadPassengers($options->passengers); |
69
|
|
|
|
70
|
|
|
$this->loadFlightDetails($options->segments); |
71
|
|
|
|
72
|
|
|
$this->loadPricingOptions($options->pricingOptions); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* |
78
|
|
|
* @param Passenger[] $passengers |
79
|
|
|
*/ |
80
|
|
|
protected function loadPassengers($passengers) |
81
|
|
|
{ |
82
|
|
|
$counter = 1; |
83
|
|
|
foreach ($passengers as $passenger) { |
84
|
|
|
$this->passengerInfoGroup[] = new PassengerInfoGroup($passenger, $counter); |
85
|
|
|
$counter ++; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* |
91
|
|
|
* @param Segment[] $segments |
92
|
|
|
*/ |
93
|
|
|
protected function loadFlightDetails($segments) |
94
|
|
|
{ |
95
|
|
|
foreach ($segments as $segment) { |
96
|
|
|
$this->flightInfo[] = new FlightInfo($segment); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* |
102
|
|
|
* @param PricingOptions|null $pricingOptions |
103
|
|
|
*/ |
104
|
|
|
protected function loadPricingOptions($pricingOptions) |
105
|
|
|
{ |
106
|
|
|
$this->pricingOption = PricePNRWithBookingClass13::loadPricingOptionsFromRequestOptions($pricingOptions); |
|
|
|
|
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|
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.