|
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\Pnr; |
|
24
|
|
|
|
|
25
|
|
|
use Amadeus\Client\RequestOptions\Pnr\Element; |
|
26
|
|
|
use Amadeus\Client\RequestOptions\Pnr\Element\ReceivedFrom; |
|
27
|
|
|
use Amadeus\Client\RequestOptions\Pnr\Segment; |
|
28
|
|
|
use Amadeus\Client\RequestOptions\Pnr\Traveller; |
|
29
|
|
|
use Amadeus\Client\RequestOptions\Pnr\TravellerGroup; |
|
30
|
|
|
use Amadeus\Client\RequestOptions\PnrAddMultiElementsBase; |
|
31
|
|
|
use Amadeus\Client\RequestOptions\PnrAddMultiElementsOptions; |
|
32
|
|
|
use Amadeus\Client\RequestOptions\PnrCreatePnrOptions; |
|
33
|
|
|
use Amadeus\Client\Struct\BaseWsMessage; |
|
34
|
|
|
use Amadeus\Client\Struct\InvalidArgumentException; |
|
35
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\Accounting; |
|
36
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\AirAuxItinerary; |
|
37
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\DataElementsIndiv; |
|
38
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\DataElementsMaster; |
|
39
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\DateOfBirth; |
|
40
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ElementManagementData; |
|
41
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ElementManagementItinerary; |
|
42
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ElementManagementPassenger; |
|
43
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\Fop; |
|
44
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\FopExtension; |
|
45
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\FormOfPayment; |
|
46
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\FreetextData; |
|
47
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\FreetextDetail; |
|
48
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\FrequentTravellerData; |
|
49
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ItineraryInfo; |
|
50
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\MiscellaneousRemark; |
|
51
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\NewFopsDetails; |
|
52
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\OriginDestinationDetails; |
|
53
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\Passenger; |
|
54
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\PassengerData; |
|
55
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\Reference; |
|
56
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ReferenceForDataElement; |
|
57
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ReferenceForSegment; |
|
58
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\ServiceRequest; |
|
59
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\StructuredAddress; |
|
60
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\TicketElement; |
|
61
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\TravellerInfo; |
|
62
|
|
|
use Amadeus\Client\Struct\Pnr\AddMultiElements\Traveller as PnrAddMultiTraveller; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Structure class for representing the PNR_AddMultiElements request message |
|
66
|
|
|
* |
|
67
|
|
|
* @package Amadeus\Client\Struct\Pnr |
|
68
|
|
|
* @author Dieter Devlieghere <[email protected]> |
|
69
|
|
|
*/ |
|
70
|
|
|
class AddMultiElements extends BaseWsMessage |
|
71
|
|
|
{ |
|
72
|
|
|
/** |
|
73
|
|
|
* @var AddMultiElements\ReservationInfo |
|
74
|
|
|
*/ |
|
75
|
|
|
public $reservationInfo; |
|
76
|
|
|
/** |
|
77
|
|
|
* @var AddMultiElements\PnrActions |
|
78
|
|
|
*/ |
|
79
|
|
|
public $pnrActions; |
|
80
|
|
|
/** |
|
81
|
|
|
* @var AddMultiElements\TravellerInfo[] |
|
82
|
|
|
*/ |
|
83
|
|
|
public $travellerInfo = []; |
|
84
|
|
|
/** |
|
85
|
|
|
* @var AddMultiElements\OriginDestinationDetails[] |
|
86
|
|
|
*/ |
|
87
|
|
|
public $originDestinationDetails = []; |
|
88
|
|
|
/** |
|
89
|
|
|
* @var AddMultiElements\DataElementsMaster |
|
90
|
|
|
*/ |
|
91
|
|
|
public $dataElementsMaster; |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Create PNR_AddMultiElements object |
|
95
|
|
|
* |
|
96
|
|
|
* @param PnrAddMultiElementsBase|null $params |
|
97
|
|
|
*/ |
|
98
|
|
|
public function __construct(PnrAddMultiElementsBase $params = null) |
|
99
|
|
|
{ |
|
100
|
|
|
if (!is_null($params)) { |
|
101
|
|
|
if ($params instanceof PnrCreatePnrOptions) { |
|
102
|
|
|
$this->loadCreatePnr($params); |
|
103
|
|
|
} else if ($params instanceof PnrAddMultiElementsOptions) { |
|
104
|
|
|
$this->loadBare($params); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* PNR_AddMultiElements call which only adds requested data to the message |
|
111
|
|
|
* |
|
112
|
|
|
* For doing specific actions like ignoring or saving PNR. |
|
113
|
|
|
* |
|
114
|
|
|
* @param $params |
|
115
|
|
|
*/ |
|
116
|
|
|
protected function loadBare(PnrAddMultiElementsOptions $params) |
|
117
|
|
|
{ |
|
118
|
|
|
if (!is_null($params->actionCode)) { |
|
119
|
|
|
$this->pnrActions = new AddMultiElements\PnrActions( |
|
120
|
|
|
$params->actionCode |
|
121
|
|
|
); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
if (!is_null($params->recordLocator)) { |
|
125
|
|
|
$this->reservationInfo = new AddMultiElements\ReservationInfo($params->recordLocator); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
$tattooCounter = 0; |
|
129
|
|
|
|
|
130
|
|
|
$this->addTravellers($params->travellers); |
|
131
|
|
|
|
|
132
|
|
|
if (!empty($params->tripSegments)) { |
|
133
|
|
|
$this->addSegments($params->tripSegments, $tattooCounter); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
if (!empty($params->elements)) { |
|
137
|
|
|
$this->addElements( |
|
138
|
|
|
$params->elements, |
|
139
|
|
|
$tattooCounter, |
|
140
|
|
|
$params->receivedFrom |
|
141
|
|
|
); |
|
142
|
|
|
} elseif (!is_null($params->receivedFrom)) { |
|
143
|
|
|
if ($this->dataElementsMaster === null) { |
|
144
|
|
|
$this->dataElementsMaster = new DataElementsMaster(); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
$tattooCounter++; |
|
148
|
|
|
|
|
149
|
|
|
$this->dataElementsMaster->dataElementsIndiv[] = $this->createElement( |
|
150
|
|
|
new ReceivedFrom(['receivedFrom' => $params->receivedFrom]), $tattooCounter |
|
151
|
|
|
); |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Make PNR_AddMultiElements structure from a PnrCreatePnrOptions input. |
|
157
|
|
|
* |
|
158
|
|
|
* @throws InvalidArgumentException When invalid input is provided |
|
159
|
|
|
* @param PnrCreatePnrOptions $params |
|
160
|
|
|
*/ |
|
161
|
|
|
protected function loadCreatePnr(PnrCreatePnrOptions $params) |
|
162
|
|
|
{ |
|
163
|
|
|
$this->pnrActions = new AddMultiElements\PnrActions( |
|
164
|
|
|
$params->actionCode |
|
165
|
|
|
); |
|
166
|
|
|
|
|
167
|
|
|
$tattooCounter = 0; |
|
168
|
|
|
|
|
169
|
|
|
if ($params->travellerGroup !== null) { |
|
170
|
|
|
$this->addTravellerGroup($params->travellerGroup); |
|
171
|
|
|
} else { |
|
172
|
|
|
$this->addTravellers($params->travellers); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
$this->addSegments($params->tripSegments, $tattooCounter); |
|
176
|
|
|
|
|
177
|
|
|
$this->addElements( |
|
178
|
|
|
$params->elements, |
|
179
|
|
|
$tattooCounter, |
|
180
|
|
|
$params->receivedFrom |
|
181
|
|
|
); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
/** |
|
185
|
|
|
* @param Segment[] $segments |
|
186
|
|
|
* @param int $tattooCounter |
|
187
|
|
|
*/ |
|
188
|
|
|
protected function addSegments($segments, &$tattooCounter) |
|
189
|
|
|
{ |
|
190
|
|
|
$tmpOrigDest = new OriginDestinationDetails(); |
|
191
|
|
|
|
|
192
|
|
|
foreach ($segments as $segment) { |
|
193
|
|
|
$tmpOrigDest->itineraryInfo[] = $this->createSegment($segment, $tattooCounter); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
$this->originDestinationDetails[] = $tmpOrigDest; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/** |
|
200
|
|
|
* @param Segment $segment |
|
201
|
|
|
* @param $tattooCounter |
|
202
|
|
|
* @return ItineraryInfo |
|
203
|
|
|
*/ |
|
204
|
|
|
protected function createSegment($segment, &$tattooCounter) |
|
205
|
|
|
{ |
|
206
|
|
|
$createdSegment = null; |
|
|
|
|
|
|
207
|
|
|
|
|
208
|
|
|
$tattooCounter++; |
|
209
|
|
|
|
|
210
|
|
|
$reflect = new \ReflectionClass($segment); |
|
211
|
|
|
$segmentType = $reflect->getShortName(); |
|
212
|
|
|
|
|
213
|
|
|
switch ($segmentType) { |
|
214
|
|
|
case 'Miscellaneous': |
|
215
|
|
|
/** @var Segment\Miscellaneous $segment */ |
|
216
|
|
|
$createdSegment = new ItineraryInfo($tattooCounter, ElementManagementItinerary::SEGMENT_MISCELLANEOUS); |
|
217
|
|
|
$createdSegment->airAuxItinerary = new AirAuxItinerary($segmentType, $segment); |
|
218
|
|
|
break; |
|
219
|
|
|
case 'Air': |
|
220
|
|
|
throw new \RuntimeException('NOT YET IMPLEMENTED'); |
|
221
|
|
|
break; |
|
|
|
|
|
|
222
|
|
|
case 'Ghost': |
|
223
|
|
|
throw new \RuntimeException('NOT YET IMPLEMENTED'); |
|
224
|
|
|
break; |
|
|
|
|
|
|
225
|
|
|
default: |
|
226
|
|
|
throw new InvalidArgumentException('Segment type ' . $segmentType . ' is not supported'); |
|
227
|
|
|
break; |
|
|
|
|
|
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
if (count($segment->references) > 0) { |
|
231
|
|
|
$createdSegment->referenceForSegment = new ReferenceForSegment(); |
|
232
|
|
|
foreach ($segment->references as $singleRef) { |
|
233
|
|
|
$createdSegment->referenceForSegment->reference[] = new Reference($singleRef->type, $singleRef->id); |
|
234
|
|
|
} |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
return $createdSegment; |
|
238
|
|
|
} |
|
239
|
|
|
|
|
240
|
|
|
|
|
241
|
|
|
/** |
|
242
|
|
|
* @param Traveller[] $travellers |
|
243
|
|
|
*/ |
|
244
|
|
|
protected function addTravellers($travellers) |
|
245
|
|
|
{ |
|
246
|
|
|
foreach ($travellers as $traveller) { |
|
247
|
|
|
$this->travellerInfo[] = $this->createTraveller($traveller); |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
/** |
|
252
|
|
|
* @param Traveller $traveller |
|
253
|
|
|
* @return TravellerInfo |
|
254
|
|
|
*/ |
|
255
|
|
|
protected function createTraveller($traveller) |
|
256
|
|
|
{ |
|
257
|
|
|
$createdTraveller = new TravellerInfo( |
|
258
|
|
|
ElementManagementPassenger::SEG_NAME, |
|
259
|
|
|
$traveller->lastName |
|
260
|
|
|
); |
|
261
|
|
|
|
|
262
|
|
|
if (!is_null($traveller->number)) { |
|
263
|
|
|
$createdTraveller->elementManagementPassenger->reference = new Reference( |
|
264
|
|
|
Reference::QUAL_PASSENGER, |
|
265
|
|
|
$traveller->number |
|
266
|
|
|
); |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
if ($traveller->firstName !== null || $traveller->travellerType !== null) { |
|
270
|
|
|
$createdTraveller->passengerData[0]->travellerInformation->passenger[] = new Passenger( |
|
271
|
|
|
$traveller->firstName, |
|
272
|
|
|
$traveller->travellerType |
|
273
|
|
|
); |
|
274
|
|
|
} |
|
275
|
|
|
|
|
276
|
|
|
if ($traveller->withInfant === true || $traveller->infant !== null) { |
|
277
|
|
|
$createdTraveller = $this->addInfant($createdTraveller, $traveller); |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
if ($traveller->dateOfBirth instanceof \DateTime) { |
|
281
|
|
|
$createdTraveller->passengerData[0]->dateOfBirth = new DateOfBirth( |
|
282
|
|
|
$traveller->dateOfBirth->format('dmY') |
|
283
|
|
|
); |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
return $createdTraveller; |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
/** |
|
290
|
|
|
* Add infant |
|
291
|
|
|
* |
|
292
|
|
|
* 3 scenario's: |
|
293
|
|
|
* - infant without additional information |
|
294
|
|
|
* - infant with only first name provided |
|
295
|
|
|
* - infant with first name, last name & date of birth provided. |
|
296
|
|
|
* |
|
297
|
|
|
* @param TravellerInfo $travellerInfo |
|
298
|
|
|
* @param Traveller $traveller |
|
299
|
|
|
* @return TravellerInfo |
|
300
|
|
|
*/ |
|
301
|
|
|
protected function addInfant($travellerInfo, $traveller) |
|
302
|
|
|
{ |
|
303
|
|
|
$travellerInfo->passengerData[0]->travellerInformation->traveller->quantity = 2; |
|
304
|
|
|
|
|
305
|
|
|
if ($traveller->withInfant && is_null($traveller->infant)) { |
|
306
|
|
|
$travellerInfo = $this->makePassengerIfNeeded($travellerInfo); |
|
307
|
|
|
$travellerInfo->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = |
|
308
|
|
|
Passenger::INF_NOINFO; |
|
309
|
|
|
|
|
310
|
|
|
} elseif ($traveller->infant instanceof Traveller) { |
|
311
|
|
|
if (empty($traveller->infant->lastName)) { |
|
312
|
|
|
$travellerInfo = $this->makePassengerIfNeeded($travellerInfo); |
|
313
|
|
|
$travellerInfo->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = |
|
314
|
|
|
Passenger::INF_GIVEN; |
|
315
|
|
|
|
|
316
|
|
|
$tmpInfantPassenger = new Passenger( |
|
317
|
|
|
$traveller->infant->firstName, |
|
318
|
|
|
Passenger::PASST_INFANT |
|
319
|
|
|
); |
|
320
|
|
|
|
|
321
|
|
|
$travellerInfo->passengerData[0]->travellerInformation->passenger[] = $tmpInfantPassenger; |
|
322
|
|
|
} else { |
|
323
|
|
|
$travellerInfo = $this->makePassengerIfNeeded($travellerInfo); |
|
324
|
|
|
$travellerInfo->passengerData[0]->travellerInformation->passenger[0]->infantIndicator = |
|
325
|
|
|
Passenger::INF_FULL; |
|
326
|
|
|
|
|
327
|
|
|
$tmpInfant = new PassengerData($traveller->infant->lastName); |
|
328
|
|
|
$tmpInfant->travellerInformation->passenger[] = new Passenger( |
|
329
|
|
|
$traveller->infant->firstName, |
|
330
|
|
|
Passenger::PASST_INFANT |
|
331
|
|
|
); |
|
332
|
|
|
|
|
333
|
|
|
if ($traveller->infant->dateOfBirth instanceof \DateTime) { |
|
334
|
|
|
$tmpInfant->dateOfBirth = new DateOfBirth( |
|
335
|
|
|
$traveller->infant->dateOfBirth->format('dmY') |
|
336
|
|
|
); |
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
$travellerInfo->passengerData[] = $tmpInfant; |
|
340
|
|
|
} |
|
341
|
|
|
} |
|
342
|
|
|
|
|
343
|
|
|
return $travellerInfo; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
/** |
|
347
|
|
|
* If there is no passenger node at |
|
348
|
|
|
* $travellerInfo->passengerData[0]->travellerInformation->passenger[0] |
|
349
|
|
|
* create one |
|
350
|
|
|
* |
|
351
|
|
|
* @param TravellerInfo $travellerInfo |
|
352
|
|
|
* @return TravellerInfo |
|
353
|
|
|
*/ |
|
354
|
|
|
protected function makePassengerIfNeeded($travellerInfo) |
|
355
|
|
|
{ |
|
356
|
|
|
if (count($travellerInfo->passengerData[0]->travellerInformation->passenger) < 1) { |
|
357
|
|
|
$travellerInfo->passengerData[0]->travellerInformation->passenger[0] = new Passenger(null, null); |
|
358
|
|
|
} |
|
359
|
|
|
|
|
360
|
|
|
return $travellerInfo; |
|
361
|
|
|
} |
|
362
|
|
|
|
|
363
|
|
|
/** |
|
364
|
|
|
* @param TravellerGroup $group |
|
365
|
|
|
*/ |
|
366
|
|
|
protected function addTravellerGroup($group) |
|
367
|
|
|
{ |
|
368
|
|
|
$groupInfo = new TravellerInfo(ElementManagementPassenger::SEG_GROUPNAME, $group->name); |
|
369
|
|
|
|
|
370
|
|
|
$groupInfo->passengerData[0]->travellerInformation->traveller->quantity = $group->nrOfTravellers; |
|
371
|
|
|
$groupInfo->passengerData[0]->travellerInformation->traveller->qualifier = PnrAddMultiTraveller::QUAL_GROUP; |
|
372
|
|
|
|
|
373
|
|
|
$this->travellerInfo[] = $groupInfo; |
|
374
|
|
|
|
|
375
|
|
|
$this->addTravellers($group->travellers); |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
/** |
|
379
|
|
|
* @param Element[] $elements |
|
380
|
|
|
* @param int $tattooCounter (BYREF) |
|
381
|
|
|
* @param string|null $receivedFromString |
|
382
|
|
|
*/ |
|
383
|
|
|
protected function addElements($elements, &$tattooCounter, $receivedFromString = null) |
|
384
|
|
|
{ |
|
385
|
|
|
if ($this->dataElementsMaster === null) { |
|
386
|
|
|
$this->dataElementsMaster = new DataElementsMaster(); |
|
387
|
|
|
} |
|
388
|
|
|
|
|
389
|
|
|
//Only add a default RF element if there is no explicitly provided RF element! |
|
390
|
|
|
$explicitRf = false; |
|
391
|
|
|
|
|
392
|
|
|
foreach ($elements as $element) { |
|
393
|
|
|
if ($element instanceof Element) { |
|
394
|
|
|
$this->dataElementsMaster->dataElementsIndiv[] = $this->createElement($element, $tattooCounter); |
|
395
|
|
|
} |
|
396
|
|
|
|
|
397
|
|
|
if ($element instanceof ReceivedFrom) { |
|
398
|
|
|
$explicitRf = true; |
|
399
|
|
|
} |
|
400
|
|
|
} |
|
401
|
|
|
|
|
402
|
|
|
if ($receivedFromString !== null && !$explicitRf) { |
|
403
|
|
|
$this->dataElementsMaster->dataElementsIndiv[] = $this->createElement( |
|
404
|
|
|
new ReceivedFrom(['receivedFrom' => $receivedFromString]), $tattooCounter |
|
405
|
|
|
); |
|
406
|
|
|
} |
|
407
|
|
|
} |
|
408
|
|
|
|
|
409
|
|
|
/** |
|
410
|
|
|
* @param Element $element |
|
411
|
|
|
* @param int $tattooCounter (BYREF) |
|
412
|
|
|
* @throws InvalidArgumentException |
|
413
|
|
|
* @return DataElementsIndiv |
|
414
|
|
|
*/ |
|
415
|
|
|
protected function createElement($element, &$tattooCounter) |
|
416
|
|
|
{ |
|
417
|
|
|
$createdElement = null; |
|
|
|
|
|
|
418
|
|
|
|
|
419
|
|
|
$tattooCounter++; |
|
420
|
|
|
|
|
421
|
|
|
$reflect = new \ReflectionClass($element); |
|
422
|
|
|
$elementType = $reflect->getShortName(); |
|
423
|
|
|
|
|
424
|
|
|
switch ($elementType) { |
|
425
|
|
|
case 'Contact': |
|
426
|
|
|
/** @var Element\Contact $element */ |
|
427
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_CONTACT_ELEMENT, $tattooCounter); |
|
428
|
|
|
$createdElement->freetextData = new FreetextData( |
|
429
|
|
|
$element->value, |
|
430
|
|
|
$element->type |
|
431
|
|
|
); |
|
432
|
|
|
break; |
|
433
|
|
|
case 'FormOfPayment': |
|
434
|
|
|
/** @var Element\FormOfPayment $element */ |
|
435
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_FORM_OF_PAYMENT, $tattooCounter); |
|
436
|
|
|
$createdElement->formOfPayment = new FormOfPayment($element->type); |
|
437
|
|
|
if ($element->type === Fop::IDENT_CREDITCARD) { |
|
438
|
|
|
$createdElement->formOfPayment->fop->creditCardCode = $element->creditCardType; |
|
439
|
|
|
$createdElement->formOfPayment->fop->accountNumber = $element->creditCardNumber; |
|
440
|
|
|
$createdElement->formOfPayment->fop->expiryDate = $element->creditCardExpiry; |
|
441
|
|
|
if (!is_null($element->creditCardCvcCode)) { |
|
442
|
|
|
$ext = new FopExtension(1); |
|
443
|
|
|
$ext->newFopsDetails = new NewFopsDetails(); |
|
444
|
|
|
$ext->newFopsDetails->cvData = $element->creditCardCvcCode; |
|
445
|
|
|
$createdElement->fopExtension[] = $ext; |
|
446
|
|
|
} |
|
447
|
|
|
} elseif ($element->type === Fop::IDENT_MISC && $element->freeText != "NONREF") { |
|
448
|
|
|
$createdElement->formOfPayment->fop->freetext = $element->freeText; |
|
449
|
|
|
} elseif ($element->type === Fop::IDENT_MISC && $element->freeText === "NONREF") { |
|
450
|
|
|
$createdElement->fopExtension[] = new FopExtension(1); |
|
451
|
|
|
} elseif ($element->type === Fop::IDENT_CHECK) { |
|
452
|
|
|
throw new \RuntimeException("FOP CHECK NOT YET IMPLEMENTED"); |
|
453
|
|
|
} |
|
454
|
|
|
break; |
|
455
|
|
|
case 'MiscellaneousRemark': |
|
456
|
|
|
/** @var Element\MiscellaneousRemark $element */ |
|
457
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_GENERAL_REMARK, $tattooCounter); |
|
458
|
|
|
$createdElement->miscellaneousRemark = new MiscellaneousRemark( |
|
459
|
|
|
$element->text, |
|
460
|
|
|
$element->type, |
|
461
|
|
|
$element->category |
|
462
|
|
|
); |
|
463
|
|
|
break; |
|
464
|
|
|
case 'ReceivedFrom': |
|
465
|
|
|
/** @var Element\ReceivedFrom $element */ |
|
466
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_RECEIVE_FROM, $tattooCounter); |
|
467
|
|
|
$createdElement->freetextData = new FreetextData( |
|
468
|
|
|
$element->receivedFrom, |
|
469
|
|
|
FreetextDetail::TYPE_RECEIVE_FROM |
|
470
|
|
|
); |
|
471
|
|
|
break; |
|
472
|
|
|
case 'ServiceRequest': |
|
473
|
|
|
/** @var Element\ServiceRequest $element */ |
|
474
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_SPECIAL_SERVICE_REQUEST, $tattooCounter); |
|
|
|
|
|
|
475
|
|
|
$createdElement->serviceRequest = new ServiceRequest($element); |
|
476
|
|
|
break; |
|
477
|
|
|
case 'Ticketing': |
|
478
|
|
|
/** @var Element\Ticketing $element */ |
|
479
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_TICKETING_ELEMENT, $tattooCounter); |
|
|
|
|
|
|
480
|
|
|
$createdElement->ticketElement = new TicketElement($element); |
|
481
|
|
|
break; |
|
482
|
|
|
case 'AccountingInfo': |
|
483
|
|
|
/** @var Element\AccountingInfo $element */ |
|
484
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_ACCOUNTING_INFORMATION, $tattooCounter); |
|
|
|
|
|
|
485
|
|
|
$createdElement->accounting = new Accounting($element); |
|
486
|
|
|
break; |
|
487
|
|
|
case 'Address': |
|
488
|
|
|
/** @var Element\Address $element */ |
|
489
|
|
|
$createdElement = new DataElementsIndiv($element->type, $tattooCounter); |
|
490
|
|
|
if ($element->type === ElementManagementData::SEGNAME_ADDRESS_BILLING_UNSTRUCTURED || $element->type === ElementManagementData::SEGNAME_ADDRESS_MAILING_UNSTRUCTURED) { |
|
|
|
|
|
|
491
|
|
|
$createdElement->freetextData = new FreetextData($element->freeText, FreetextDetail::TYPE_MAILING_ADDRESS); |
|
|
|
|
|
|
492
|
|
|
} else { |
|
493
|
|
|
$createdElement->structuredAddress = new StructuredAddress($element); |
|
494
|
|
|
} |
|
495
|
|
|
break; |
|
496
|
|
|
case 'FrequentFlyer': |
|
497
|
|
|
/** @var Element\FrequentFlyer $element */ |
|
498
|
|
|
$createdElement = new DataElementsIndiv(ElementManagementData::SEGNAME_SPECIAL_SERVICE_REQUEST, $tattooCounter); |
|
|
|
|
|
|
499
|
|
|
$createdElement->serviceRequest = new ServiceRequest(); |
|
500
|
|
|
$createdElement->serviceRequest->ssr->type = 'FQTV'; |
|
501
|
|
|
$createdElement->serviceRequest->ssr->companyId = $element->airline; |
|
502
|
|
|
$createdElement->frequentTravellerData = new FrequentTravellerData($element); |
|
503
|
|
|
break; |
|
504
|
|
|
default: |
|
505
|
|
|
throw new InvalidArgumentException('Element type ' . $elementType . ' is not supported'); |
|
506
|
|
|
} |
|
507
|
|
|
|
|
508
|
|
|
if (!empty($element->references)) { |
|
509
|
|
|
$createdElement->referenceForDataElement = new ReferenceForDataElement($element->references); |
|
510
|
|
|
} |
|
511
|
|
|
|
|
512
|
|
|
return $createdElement; |
|
513
|
|
|
} |
|
514
|
|
|
} |
|
515
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.