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\SegmentGroup; |
27
|
|
|
use Amadeus\Client\Struct\Fare\InformativePricing13\SegmentInformation; |
28
|
|
|
use Amadeus\Client\Struct\Air\FlightTypeDetails; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* FlightInfo |
32
|
|
|
* |
33
|
|
|
* @package Amadeus\Client\Struct\Service\StandaloneCatalogue |
34
|
|
|
* @author Arvind Pandey <[email protected]> |
35
|
|
|
*/ |
36
|
|
|
class FlightInfo extends SegmentGroup |
37
|
|
|
{ |
38
|
|
|
/** |
39
|
|
|
* @var SegmentInformation |
40
|
|
|
*/ |
41
|
|
|
public $flightDetails; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* FlightInfo constructor. |
45
|
|
|
* |
46
|
|
|
* @param Segment $options |
47
|
|
|
*/ |
48
|
|
View Code Duplication |
public function __construct($options) |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
$this->flightDetails = new SegmentInformation( |
51
|
|
|
$options->segmentTattoo, |
52
|
|
|
$options->departureDate, |
53
|
|
|
$options->from, |
54
|
|
|
$options->to, |
55
|
|
|
$options->marketingCompany, |
56
|
|
|
$options->flightNumber, |
57
|
|
|
$options->bookingClass |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
$this->loadOptionalSegmentInformation($options); |
|
|
|
|
61
|
|
|
|
62
|
|
|
SegmentGroup::loadInventory($options->inventory); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Load non-required options if available |
67
|
|
|
* |
68
|
|
|
* @param FlightInfo $options |
69
|
|
|
*/ |
70
|
|
View Code Duplication |
protected function loadOptionalSegmentInformation($options) |
|
|
|
|
71
|
|
|
{ |
72
|
|
|
if (! empty($options->operatingCompany)) { |
73
|
|
|
$this->flightDetails->companyDetails->operatingCompany = $options->operatingCompany; |
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
if ($options->arrivalDate instanceof \DateTime) { |
77
|
|
|
$this->flightDetails->flightDate->setArrivalDate($options->arrivalDate); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
if (! empty($options->groupNumber)) { |
81
|
|
|
$this->flightDetails->flightTypeDetails = new FlightTypeDetails($options->groupNumber); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
SegmentGroup::loadAdditionalSegmentDetails($options->airplaneCode, $options->nrOfStops); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
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.