RetrieveSeatMap   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 137
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 16
eloc 40
c 1
b 0
f 0
dl 0
loc 137
ccs 49
cts 49
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A loadConversionRate() 0 4 2
A loadPassengers() 0 4 2
A __construct() 0 22 4
A loadSeatRequestParameters() 0 6 3
A loadProductInformation() 0 6 3
A loadRecordLocator() 0 7 2
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\ProcessIndicators;
16
use Amadeus\Client\Struct\Air\RetrieveSeatMap\ProductInformation;
17
use Amadeus\Client\Struct\Air\RetrieveSeatMap\ResControlInfo;
18
use Amadeus\Client\Struct\Air\RetrieveSeatMap\SeatRequestParameters;
19
use Amadeus\Client\Struct\Air\RetrieveSeatMap\StatusInformation;
20
use Amadeus\Client\Struct\Air\RetrieveSeatMap\Traveller;
21
use Amadeus\Client\Struct\Air\RetrieveSeatMap\TravelProductIdent;
22
use Amadeus\Client\Struct\BaseWsMessage;
23
24
/**
25
 * RetrieveSeatMap
26
 *
27
 * @package Amadeus\Client\Struct\Air
28
 * @author Dieter Devlieghere <[email protected]>
29
 */
30
class RetrieveSeatMap extends BaseWsMessage
31
{
32
    /**
33
     * @var RetrieveSeatMap\TravelProductIdent
34
     */
35
    public $travelProductIdent;
36
37
    /**
38
     * @var RetrieveSeatMap\SeatRequestParameters
39
     */
40
    public $seatRequestParameters;
41
42
    /**
43
     * @var RetrieveSeatMap\ProductInformation
44
     */
45
    public $productInformation;
46
47
    /**
48
     * @var RetrieveSeatMap\FrequentTravelerInfo
49
     */
50
    public $frequentTravelerInfo;
51
52
    /**
53
     * @var RetrieveSeatMap\ResControlInfo
54
     */
55
    public $resControlInfo;
56
57
    public $equipmentInformation;
58
59
    public $additionalInfo;
60
61
    /**
62
     * @var RetrieveSeatMap\ConversionRate
63
     */
64
    public $conversionRate;
65
66
    /**
67
     * @var RetrieveSeatMap\Traveller[]
68
     */
69
    public $traveler = [];
70
71
    public $suitablePassenger;
72
73
    /**
74
     * @var ProcessIndicators
75
     */
76
    public $processIndicators;
77
78
79
80
    /**
81
     * RetrieveSeatMap constructor.
82
     *
83
     * @param AirRetrieveSeatMapOptions $options
84
     */
85 45
    public function __construct(AirRetrieveSeatMapOptions $options)
86
    {
87 45
        if ($options->flight instanceof RequestFlightInfo) {
0 ignored issues
show
introduced by
$options->flight is always a sub-type of Amadeus\Client\RequestOp...rieveSeatMap\FlightInfo.
Loading history...
88 45
            $this->travelProductIdent = new TravelProductIdent($options->flight);
89 18
        }
90
91 45
        if ($options->frequentFlyer instanceof FrequentFlyer) {
0 ignored issues
show
introduced by
$options->frequentFlyer is always a sub-type of Amadeus\Client\RequestOp...veSeatMap\FrequentFlyer.
Loading history...
92 5
            $this->frequentTravelerInfo = new FrequentTravelerInfo($options->frequentFlyer);
93 2
        }
94
95 45
        $this->loadSeatRequestParameters($options);
96
97 45
        $this->loadConversionRate($options);
98
99 45
        $this->loadRecordLocator($options);
100
101 45
        $this->loadProductInformation($options);
102
103 45
        $this->loadPassengers($options);
104
105 45
        if ($options->mostRestrictive) {
106 5
            $this->processIndicators = new ProcessIndicators(StatusInformation::ACTION_MOST_RESTRICTIVE);
107 2
        }
108 45
    }
109
110
    /**
111
     * @param AirRetrieveSeatMapOptions $options
112
     */
113 45
    protected function loadSeatRequestParameters($options)
114
    {
115 45
        if (!empty($options->cabinCode) || $options->requestPrices === true) {
116 10
            $this->seatRequestParameters = new SeatRequestParameters(
117 10
                $options->cabinCode,
118 10
                $options->requestPrices
119 4
            );
120 4
        }
121 45
    }
122
123
    /**
124
     * @param AirRetrieveSeatMapOptions $options
125
     */
126 45
    protected function loadRecordLocator($options)
127
    {
128 45
        if (!empty($options->recordLocator)) {
129 15
            $this->resControlInfo = new ResControlInfo(
130 15
                $options->recordLocator,
131 15
                $options->company,
132 15
                $options->date
133 6
            );
134 6
        }
135 45
    }
136
137
    /**
138
     * @param AirRetrieveSeatMapOptions $options
139
     */
140 45
    protected function loadProductInformation($options)
141
    {
142 45
        if (!empty($options->nrOfPassengers) || !empty($options->bookingStatus)) {
143 5
            $this->productInformation = new ProductInformation(
144 5
                $options->nrOfPassengers,
145 5
                $options->bookingStatus
146 2
            );
147 2
        }
148 45
    }
149
150
    /**
151
     * @param AirRetrieveSeatMapOptions $options
152
     */
153 45
    protected function loadConversionRate($options)
154
    {
155 45
        if (!empty($options->currency)) {
156 5
            $this->conversionRate = new ConversionRate($options->currency);
157 2
        }
158 45
    }
159
160
    /**
161
     * @param AirRetrieveSeatMapOptions $options
162
     */
163 45
    protected function loadPassengers($options)
164
    {
165 45
        foreach ($options->travellers as $traveller) {
166 5
            $this->traveler[] = new Traveller($traveller);
167 18
        }
168 45
    }
169
}
170