|
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\Service\StandaloneCatalogue; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\Fare\InformativePricing\Segment; |
|
26
|
|
|
use Amadeus\Client\Struct\Fare\InformativePricing13\SegmentInformation; |
|
27
|
|
|
use Amadeus\Client\Struct\Air\FlightTypeDetails; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* FlightInfo |
|
31
|
|
|
* |
|
32
|
|
|
* @package Amadeus\Client\Struct\Service\StandaloneCatalogue |
|
33
|
|
|
* @author Arvind Pandey <[email protected]> |
|
34
|
|
|
*/ |
|
35
|
|
View Code Duplication |
class FlightInfo |
|
|
|
|
|
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* @var flightDetails |
|
39
|
|
|
*/ |
|
40
|
|
|
public $flightDetails; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var AdditionalSegmentDetails |
|
44
|
|
|
*/ |
|
45
|
|
|
public $additionnalSegmentDetails; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var Inventory |
|
49
|
|
|
*/ |
|
50
|
|
|
public $inventory; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* SegmentGroup constructor. |
|
54
|
|
|
* |
|
55
|
|
|
* @param Segment $options |
|
56
|
|
|
*/ |
|
57
|
|
|
public function __construct($options) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->flightDetails = new SegmentInformation( |
|
|
|
|
|
|
60
|
|
|
$options->segmentTattoo, |
|
61
|
|
|
$options->departureDate, |
|
62
|
|
|
$options->from, |
|
63
|
|
|
$options->to, |
|
64
|
|
|
$options->marketingCompany, |
|
65
|
|
|
$options->flightNumber, |
|
66
|
|
|
$options->bookingClass |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$this->loadOptionalSegmentInformation($options); |
|
70
|
|
|
|
|
71
|
|
|
$this->loadInventory($options->inventory); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Load non-required options if available |
|
76
|
|
|
* |
|
77
|
|
|
* @param Segment $options |
|
78
|
|
|
*/ |
|
79
|
|
|
protected function loadOptionalSegmentInformation($options) |
|
80
|
|
|
{ |
|
81
|
|
|
if (!empty($options->operatingCompany)) { |
|
82
|
|
|
$this->flightDetails->companyDetails->operatingCompany = $options->operatingCompany; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
if ($options->arrivalDate instanceof \DateTime) { |
|
86
|
|
|
$this->flightDetails->flightDate->setArrivalDate($options->arrivalDate); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
if (!empty($options->groupNumber)) { |
|
90
|
|
|
$this->flightDetails->flightTypeDetails = new FlightTypeDetails($options->groupNumber); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$this->loadAdditionalSegmentDetails($options->airplaneCode, $options->nrOfStops); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* @param string|null $airplaneCode |
|
98
|
|
|
* @param int|null $nrOfStops |
|
99
|
|
|
*/ |
|
100
|
|
|
protected function loadAdditionalSegmentDetails($airplaneCode, $nrOfStops) |
|
101
|
|
|
{ |
|
102
|
|
|
if (!empty($airplaneCode) || !empty($nrOfStops)) { |
|
103
|
|
|
$this->additionalFlightInfo = new AdditionalSegmentDetails($airplaneCode, $nrOfStops); |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Load inventory information |
|
109
|
|
|
* |
|
110
|
|
|
* @param array $inventory |
|
111
|
|
|
*/ |
|
112
|
|
|
protected function loadInventory($inventory) |
|
113
|
|
|
{ |
|
114
|
|
|
if (is_array($inventory) && count($inventory) > 0) { |
|
115
|
|
|
$this->inventory = new Inventory(); |
|
116
|
|
|
|
|
117
|
|
|
foreach ($inventory as $bookingClass => $availabilityAmount) { |
|
118
|
|
|
$this->inventory->bookingClassDetails[] = new BookingClassDetails( |
|
119
|
|
|
$bookingClass, |
|
120
|
|
|
$availabilityAmount |
|
121
|
|
|
); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
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.