MasterPricerExpertSearch::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
ccs 2
cts 2
cp 1
cc 2
nc 2
nop 1
crap 2
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\Fare;
24
25
use Amadeus\Client\RequestOptions\Fare\MPFareFamily;
26
use Amadeus\Client\RequestOptions\Fare\MPItinerary;
27
use Amadeus\Client\RequestOptions\FareMasterPricerCalendarOptions;
28
use Amadeus\Client\RequestOptions\FareMasterPricerExSearchOptions;
29
use Amadeus\Client\RequestOptions\TicketAtcShopperMpTbSearchOptions;
30
use Amadeus\Client\Struct\Fare\MasterPricer;
31
32
/**
33
 * Fare_MasterPricerExpertSearch message structure
34
 *
35
 * @package Amadeus\Client\Struct\Fare
36
 * @author Dieter Devlieghere <[email protected]>
37
 */
38
class MasterPricerExpertSearch extends BaseMasterPricerMessage
39
{
40
    /**
41
     * @var mixed
42
     */
43
    public $globalOptions;
44
    /**
45
     * @var MasterPricer\CustomerRef
46
     */
47
    public $customerRef;
48
    /**
49
     * @var mixed
50
     */
51
    public $formOfPaymentByPassenger;
52
    /**
53
     * @var mixed
54
     */
55
    public $solutionFamily;
56
    /**
57
     * @var mixed[]
58
     */
59
    public $passengerInfoGrp = [];
60
    /**
61
     * @var MasterPricer\FareFamilies[]
62
     */
63
    public $fareFamilies = [];
64
    /**
65
     * @var MasterPricer\PriceToBeat
66
     */
67
    public $priceToBeat;
68
    /**
69
     * @var mixed
70
     */
71
    public $taxInfo;
72
    /**
73
     * @var MasterPricer\TravelFlightInfo
74
     */
75
    public $travelFlightInfo;
76
    /**
77
     * @var array
78
     */
79
    public $valueSearch = [];
80
    /**
81
     * Itinerary
82
     *
83
     * @var MasterPricer\Itinerary[]
84
     */
85
    public $itinerary = [];
86
    /**
87
     * @var mixed
88
     */
89
    public $ticketChangeInfo;
90
    /**
91
     * @var mixed
92
     */
93
    public $combinationFareFamilies;
94
    /**
95
     * @var MasterPricer\FeeOption[]
96
     */
97
    public $feeOption;
98
    /**
99
     * @var MasterPricer\OfficeIdDetails[]
100
     */
101
    public $officeIdDetails;
102
103
    /**
104
     * MasterPricerExpertSearch constructor.
105
     *
106
     * @param FareMasterPricerExSearch|FareMasterPricerCalendarOptions|TicketAtcShopperMpExSearchOptions|null $options
0 ignored issues
show
Bug introduced by
The type Amadeus\Client\Struct\Fa...hopperMpExSearchOptions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type Amadeus\Client\Struct\Fa...areMasterPricerExSearch was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
107
     */
108
    public function __construct($options = null)
109 165
    {
110
        if ($options instanceof FareMasterPricerExSearchOptions) {
111 165
            $this->loadOptions($options);
112 165
        }
113 66
    }
114 165
115
    /**
116
     * @param FareMasterPricerExSearch|FareMasterPricerCalendarOptions|TicketAtcShopperMpExSearchOptions $options
117
     */
118
    protected function loadOptions($options)
119 165
    {
120
        $this->loadNumberOfUnits($options);
121 165
122
        $this->loadFareOptions($options);
123 165
124
        $passengerCounter = 1;
125 165
        $infantCounter = 1;
126 165
        foreach ($options->passengers as $passenger) {
127 165
            $this->loadPassenger($passenger, $passengerCounter, $infantCounter);
128 150
        }
129 66
130
        $segmentCounter = 1;
131 165
        foreach ($options->itinerary as $itinerary) {
132 165
            $this->loadItinerary($itinerary, $segmentCounter);
133 150
        }
134 66
135
        foreach ($options->officeIds as $officeId) {
136 165
            $this->loadOfficeId($officeId);
137 5
        }
138 66
139
        if ($this->checkAnyNotEmpty(
140 165
            $options->cabinClass,
141 165
            $options->cabinOption,
142 165
            $options->requestedFlightTypes,
143 165
            $options->airlineOptions,
144 165
            $options->progressiveLegsMin,
145 165
            $options->progressiveLegsMax,
146 165
            $options->maxLayoverPerConnectionHours,
147 165
            $options->maxLayoverPerConnectionMinutes
148 165
        )) {
149 66
            $this->travelFlightInfo = new MasterPricer\TravelFlightInfo(
150 45
                $options->cabinClass,
151 45
                $options->cabinOption,
152 45
                $options->requestedFlightTypes,
153 45
                $options->airlineOptions,
154 45
                $options->progressiveLegsMin,
155 45
                $options->progressiveLegsMax,
156 45
                $options->maxLayoverPerConnectionHours,
157 45
                $options->maxLayoverPerConnectionMinutes
158 45
            );
159 18
        }
160 18
161
        if (!empty($options->priceToBeat)) {
162 165
            $this->priceToBeat = new MasterPricer\PriceToBeat(
163 5
                $options->priceToBeat,
164 5
                $options->priceToBeatCurrency
165 5
            );
166 2
        }
167 2
168
        $this->loadFareFamilies($options->fareFamilies);
169 165
170
        $this->loadCustomerRefs($options->dkNumber);
171 165
172
        $this->loadFeeOptions($options->feeOption);
173 165
    }
174 165
175
    /**
176
     * @param string $officeId
177
     */
178
    protected function loadOfficeId($officeId)
179 5
    {
180
        $this->officeIdDetails[] = new MasterPricer\OfficeIdDetails($officeId);
181 5
    }
182 5
183
    /**
184
     * @param MPItinerary $opt
185
     * @param int $counter BYREF
186
     */
187
    protected function loadItinerary($opt, &$counter)
188 150
    {
189
        $segmentRef = $counter;
190 150
191
        if (!empty($opt->segmentReference)) {
192 150
            $segmentRef = $opt->segmentReference;
193
        }
194
195
        $tmpItinerary = new MasterPricer\Itinerary($segmentRef);
196 150
197
        $tmpItinerary->departureLocalization = new MasterPricer\DepartureLocalization(
198 150
            $opt->departureLocation
199 150
        );
200 60
        $tmpItinerary->arrivalLocalization = new MasterPricer\ArrivalLocalization(
201 150
            $opt->arrivalLocation
202 150
        );
203 60
        $tmpItinerary->timeDetails = new MasterPricer\TimeDetails($opt->date);
204 150
205
        if ($this->checkAnyNotEmpty(
206 150
            $opt->airlineOptions,
207 150
            $opt->requestedFlightTypes,
208 150
            $opt->includedConnections,
209 150
            $opt->excludedConnections,
210 150
            $opt->nrOfConnections,
211 150
            $opt->cabinClass,
212 150
            $opt->cabinOption
213 150
        )) {
214 60
            $tmpItinerary->flightInfo = new MasterPricer\FlightInfo(
215 25
                $opt->airlineOptions,
216 25
                $opt->requestedFlightTypes,
217 25
                $opt->includedConnections,
218 25
                $opt->excludedConnections,
219 25
                $opt->nrOfConnections,
220 25
                null,
221 25
                $opt->cabinClass,
222 25
                $opt->cabinOption
223 25
            );
224 10
        }
225 10
226
        $this->itinerary[] = $tmpItinerary;
227 150
228
        $counter++;
229 150
    }
230 150
231
    /**
232
     * @param MPFareFamily[] $fareFamilies
233
     */
234
    protected function loadFareFamilies($fareFamilies)
235 165
    {
236
        foreach ($fareFamilies as $fareFamily) {
237 165
            $this->fareFamilies[] = new MasterPricer\FareFamilies($fareFamily);
238 10
        }
239 66
    }
240 165
241
    /**
242
     * Load Customer references
243
     *
244
     * @param string $dkNumber
245
     */
246
    protected function loadCustomerRefs($dkNumber)
247 165
    {
248
        if (!is_null($dkNumber)) {
0 ignored issues
show
introduced by
The condition is_null($dkNumber) is always false.
Loading history...
249 165
            $this->customerRef = new MasterPricer\CustomerRef();
250 5
            $this->customerRef->customerReferences[] = new MasterPricer\CustomerReferences(
251 5
                $dkNumber,
252 5
                MasterPricer\CustomerReferences::QUAL_AGENCY_GROUPING_ID
253 3
            );
254 2
        }
255 2
    }
256 165
257
    private function loadFeeOptions($feeOptions)
258 165
    {
259
        if (!is_null($feeOptions)) {
260 165
            foreach ($feeOptions as $feeOption) {
261 165
                $this->feeOption[] = new MasterPricer\FeeOption($feeOption);
262 5
            }
263 66
        }
264 66
    }
265
}
266