Completed
Push — master ( 0b0e41...92762b )
by Dieter
06:46
created

RetrieveSeatMap::loadPassengers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
/**
3
 * Amadeus
4
 *
5
 * Copyright 2015 Amadeus Benelux NV
6
 */
7
8
namespace Amadeus\Client\Struct\Air;
9
10
use Amadeus\Client\RequestOptions\Air\RetrieveSeatMap\FlightInfo as RequestFlightInfo;
11
use Amadeus\Client\RequestOptions\Air\RetrieveSeatMap\FrequentFlyer;
12
use Amadeus\Client\RequestOptions\AirRetrieveSeatMapOptions;
13
use Amadeus\Client\Struct\Air\RetrieveSeatMap\ConversionRate;
14
use Amadeus\Client\Struct\Air\RetrieveSeatMap\FrequentTravelerInfo;
15
use Amadeus\Client\Struct\Air\RetrieveSeatMap\ProductInformation;
16
use Amadeus\Client\Struct\Air\RetrieveSeatMap\ResControlInfo;
17
use Amadeus\Client\Struct\Air\RetrieveSeatMap\SeatRequestParameters;
18
use Amadeus\Client\Struct\Air\RetrieveSeatMap\Traveller;
19
use Amadeus\Client\Struct\Air\RetrieveSeatMap\TravelProductIdent;
20
use Amadeus\Client\Struct\BaseWsMessage;
21
22
/**
23
 * RetrieveSeatMap
24
 *
25
 * @package Amadeus\Client\Struct\Air
26
 * @author Dieter Devlieghere <[email protected]>
27
 */
28
class RetrieveSeatMap extends BaseWsMessage
29
{
30
    /**
31
     * @var RetrieveSeatMap\TravelProductIdent
32
     */
33
    public $travelProductIdent;
34
35
    /**
36
     * @var RetrieveSeatMap\SeatRequestParameters
37
     */
38
    public $seatRequestParameters;
39
40
    /**
41
     * @var RetrieveSeatMap\ProductInformation
42
     */
43
    public $productInformation;
44
45
    /**
46
     * @var RetrieveSeatMap\FrequentTravelerInfo
47
     */
48
    public $frequentTravelerInfo;
49
50
    /**
51
     * @var RetrieveSeatMap\ResControlInfo
52
     */
53
    public $resControlInfo;
54
55
    public $equipmentInformation;
56
57
    public $additionalInfo;
58
59
    /**
60
     * @var RetrieveSeatMap\ConversionRate
61
     */
62
    public $conversionRate;
63
64
    /**
65
     * @var RetrieveSeatMap\Traveller[]
66
     */
67
    public $traveler = [];
68
69
    public $suitablePassenger;
70
71
    public $processIndicators;
72
73
74
75
    /**
76
     * RetrieveSeatMap constructor.
77
     *
78
     * @param AirRetrieveSeatMapOptions $options
79
     */
80
    public function __construct(AirRetrieveSeatMapOptions $options)
81
    {
82
        if ($options->flight instanceof RequestFlightInfo) {
83
            $this->travelProductIdent = new TravelProductIdent($options->flight);
84
        }
85
86
        if ($options->frequentFlyer instanceof FrequentFlyer) {
87
            $this->frequentTravelerInfo = new FrequentTravelerInfo($options->frequentFlyer);
88
        }
89
90
        $this->loadSeatRequestParameters($options);
91
92
        $this->loadConversionRate($options);
93
94
        $this->loadRecordLocator($options);
95
96
        $this->loadProductInformation($options);
97
98
        $this->loadPassengers($options);
99
    }
100
101
    /**
102
     * @param AirRetrieveSeatMapOptions $options
103
     */
104
    protected function loadSeatRequestParameters($options)
105
    {
106
        if (!empty($options->cabinCode) || $options->requestPrices === true) {
107
            $this->seatRequestParameters = new SeatRequestParameters(
108
                $options->cabinCode,
109
                $options->requestPrices
110
            );
111
        }
112
    }
113
114
    /**
115
     * @param AirRetrieveSeatMapOptions $options
116
     */
117
    protected function loadRecordLocator($options)
118
    {
119
        if (!empty($options->recordLocator)) {
120
            $this->resControlInfo = new ResControlInfo($options->recordLocator);
121
        }
122
    }
123
124
    /**
125
     * @param AirRetrieveSeatMapOptions $options
126
     */
127
    protected function loadProductInformation($options)
128
    {
129
        if (!empty($options->nrOfPassengers) || !empty($options->bookingStatus)) {
130
            $this->productInformation = new ProductInformation(
131
                $options->nrOfPassengers,
132
                $options->bookingStatus
133
            );
134
        }
135
    }
136
137
    /**
138
     * @param AirRetrieveSeatMapOptions $options
139
     */
140
    protected function loadConversionRate($options)
141
    {
142
        if (!empty($options->currency)) {
143
            $this->conversionRate = new ConversionRate($options->currency);
144
        }
145
    }
146
147
    /**
148
     * @param AirRetrieveSeatMapOptions $options
149
     */
150
    protected function loadPassengers($options)
151
    {
152
        foreach ($options->travellers as $traveller) {
153
            $this->traveler[] = new Traveller($traveller);
154
        }
155
    }
156
}
157