Completed
Push — develop ( 85d412...a52dc0 )
by Dieter
07:33
created

Client::airRetrieveSeatMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 19
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 19
loc 19
rs 9.4285
cc 1
eloc 12
nc 1
nop 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;
24
25
use Amadeus\Client\Exception;
26
use Amadeus\Client\Params;
27
use Amadeus\Client\RequestCreator\RequestCreatorInterface;
28
use Amadeus\Client\RequestOptions;
29
use Amadeus\Client\ResponseHandler\ResponseHandlerInterface;
30
use Amadeus\Client\Result;
31
use Amadeus\Client\Session\Handler\HandlerFactory;
32
use Amadeus\Client\RequestCreator\Factory as RequestCreatorFactory;
33
use Amadeus\Client\Session\Handler\HandlerInterface;
34
use Amadeus\Client\ResponseHandler\Base as ResponseHandlerBase;
35
36
/**
37
 * Amadeus Web Service Client.
38
 *
39
 * TODO:
40
 * - support older versions of SoapHeader (1)
41
 * - implement calls for full online booking flow:
42
 *      SalesReports_DisplayQueryReport
43
 *      Air_MultiAvailability
44
 *
45
 * - implement more PNR_AddMultiElements:
46
 *      OSI segment
47
 *
48
 * @package Amadeus
49
 * @author Dieter Devlieghere <[email protected]>
50
 */
51
class Client
52
{
53
    /**
54
     * Amadeus SOAP header version 1
55
     */
56
    const HEADER_V1 = "1";
57
    /**
58
     * Amadeus SOAP header version 2
59
     */
60
    const HEADER_V2 = "2";
61
    /**
62
     * Amadeus SOAP header version 4
63
     */
64
    const HEADER_V4 = "4";
65
66
    /**
67
     * Version string
68
     *
69
     * @var string
70
     */
71
    const version = "0.0.1dev";
72
    /**
73
     * An identifier string for the library (to be used in Received From entries)
74
     *
75
     * @var string
76
     */
77
    const receivedFromIdentifier = "amabnl-amadeus-ws-client";
78
79
    /**
80
     * Session Handler will be sending all the messages and handling all session-related things.
81
     *
82
     * @var HandlerInterface
83
     */
84
    protected $sessionHandler;
85
86
    /**
87
     * Request Creator is will create the correct message structure to send to the SOAP server.
88
     *
89
     * @var RequestCreatorInterface
90
     */
91
    protected $requestCreator;
92
93
    /**
94
     * Response Handler will check the received response for errors.
95
     *
96
     * @var ResponseHandlerInterface
97
     */
98
    protected $responseHandler;
99
100
    /**
101
     * Authentication parameters
102
     *
103
     * @var Params\AuthParams
104
     */
105
    protected $authParams;
106
107
    /**
108
     * Set the session as stateful (true) or stateless (false)
109
     *
110
     * @param bool $newStateful
111
     */
112
    public function setStateful($newStateful)
113
    {
114
        $this->sessionHandler->setStateful($newStateful);
115
    }
116
117
    /**
118
     * @return bool
119
     */
120
    public function isStateful()
121
    {
122
        return $this->sessionHandler->isStateful();
123
    }
124
125
    /**
126
     * Get the last raw XML message that was sent out
127
     *
128
     * @return string|null
129
     */
130
    public function getLastRequest()
131
    {
132
        return $this->sessionHandler->getLastRequest();
133
    }
134
135
    /**
136
     * Get the last raw XML message that was received
137
     *
138
     * @return string|null
139
     */
140
    public function getLastResponse()
141
    {
142
        return $this->sessionHandler->getLastResponse();
143
    }
144
145
    /**
146
     * Get session information for authenticated session
147
     *
148
     * - sessionId
149
     * - sequenceNr
150
     * - securityToken
151
     *
152
     * @return array|null
153
     */
154
    public function getSessionData()
155
    {
156
        return $this->sessionHandler->getSessionData();
157
    }
158
159
    /**
160
     * Restore a previously used session
161
     *
162
     * To be used when implementing your own session pooling system on legacy Soap Header 2 applications.
163
     *
164
     * @param array $sessionData
165
     * @return bool
166
     */
167
    public function setSessionData(array $sessionData)
168
    {
169
        return $this->sessionHandler->setSessionData($sessionData);
170
    }
171
172
    /**
173
     * Construct Amadeus Web Services client
174
     *
175
     * @param Params $params
176
     */
177
    public function __construct($params)
178
    {
179
        if ($params->authParams instanceof Params\AuthParams) {
180
            $this->authParams = $params->authParams;
181
            if (isset($params->sessionHandlerParams) && $params->sessionHandlerParams instanceof Params\SessionHandlerParams) {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
182
                $params->sessionHandlerParams->authParams = $this->authParams;
183
            }
184
        }
185
186
        $this->sessionHandler = $this->loadSessionHandler(
187
            $params->sessionHandler,
188
            $params->sessionHandlerParams
0 ignored issues
show
Bug introduced by
It seems like $params->sessionHandlerParams can be null; however, loadSessionHandler() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
189
        );
190
191
        $this->requestCreator = $this->loadRequestCreator(
192
            $params->requestCreator,
193
            $params->requestCreatorParams,
194
            self::receivedFromIdentifier . "-" .self::version,
195
            $this->sessionHandler->getOriginatorOffice(),
196
            $this->sessionHandler->getMessagesAndVersions()
197
        );
198
199
        $this->responseHandler = $this->loadResponseHandler(
200
            $params->responseHandler
201
        );
202
    }
203
204
    /**
205
     * Authenticate.
206
     *
207
     * Parameters were provided at construction time (sessionhandlerparams)
208
     *
209
     * @return Result
210
     * @throws Exception
211
     */
212 View Code Duplication
    public function securityAuthenticate()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
213
    {
214
        $msgName = 'Security_Authenticate';
215
        $messageOptions = $this->makeMessageOptions([], false);
216
217
        $sendResult = $this->sessionHandler->sendMessage(
218
            $msgName,
219
            $this->requestCreator->createRequest(
220
                $msgName,
221
                new RequestOptions\SecurityAuthenticateOptions(
222
                    $this->authParams
223
                )
224
            ),
225
            $messageOptions
226
        );
227
228
        return $this->responseHandler->analyzeResponse(
229
            $sendResult,
230
            $msgName
231
        );
232
    }
233
234
    /**
235
     * Terminate a session - only applicable to non-stateless mode.
236
     *
237
     * @return Result
238
     * @throws Exception
239
     */
240 View Code Duplication
    public function securitySignOut()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
241
    {
242
        $msgName = 'Security_SignOut';
243
        $messageOptions = $this->makeMessageOptions([], true);
244
245
        $sendResult = $this->sessionHandler->sendMessage(
246
            $msgName,
247
            $this->requestCreator->createRequest(
248
                $msgName,
249
                new RequestOptions\SecuritySignOutOptions()
250
            ),
251
            $messageOptions
252
        );
253
254
        return $this->responseHandler->analyzeResponse(
255
            $sendResult,
256
            $msgName
257
        );
258
    }
259
260
    /**
261
     * PNR_Retrieve - Retrieve an Amadeus PNR by record locator
262
     *
263
     * By default, the result will be the PNR_Reply XML as string.
264
     * That way you can easily parse the PNR's contents with XPath.
265
     *
266
     * https://webservices.amadeus.com/extranet/viewService.do?id=27&flavourId=1&menuId=functional
267
     *
268
     * @param RequestOptions\PnrRetrieveOptions $options
269
     * @param array $messageOptions (OPTIONAL) Set ['asString'] = 'false' to get PNR_Reply as a PHP object.
270
     * @return Result
271
     * @throws Exception
272
     */
273 View Code Duplication
    public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
274
    {
275
        $msgName = 'PNR_Retrieve';
276
        $messageOptions = $this->makeMessageOptions($messageOptions);
277
278
        $sendResult = $this->sessionHandler->sendMessage(
279
            $msgName,
280
            $this->requestCreator->createRequest(
281
                $msgName,
282
                $options
283
            ),
284
            $messageOptions
285
        );
286
287
        return $this->responseHandler->analyzeResponse(
288
            $sendResult,
289
            $msgName
290
        );
291
    }
292
293
    /**
294
     * Create a PNR using PNR_AddMultiElements
295
     *
296
     * @param RequestOptions\PnrCreatePnrOptions $options
297
     * @param array $messageOptions
298
     * @return Result
299
     */
300 View Code Duplication
    public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
301
    {
302
        $msgName = 'PNR_AddMultiElements';
303
        $messageOptions = $this->makeMessageOptions($messageOptions);
304
305
        $sendResult = $this->sessionHandler->sendMessage(
306
            $msgName,
307
            $this->requestCreator->createRequest(
308
                $msgName,
309
                $options
310
            ),
311
            $messageOptions
312
        );
313
314
        return $this->responseHandler->analyzeResponse(
315
            $sendResult,
316
            $msgName
317
        );
318
    }
319
320
    /**
321
     * PNR_AddMultiElements - Create a new PNR or update an existing PNR.
322
     *
323
     * https://webservices.amadeus.com/extranet/viewService.do?id=25&flavourId=1&menuId=functional
324
     *
325
     * @todo implement message creation - maybe split up in separate Create & Modify PNR?
326
     * @param RequestOptions\PnrAddMultiElementsOptions $options
327
     * @param array $messageOptions
328
     * @return Result
329
     */
330 View Code Duplication
    public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
331
    {
332
        $msgName = 'PNR_AddMultiElements';
333
        $messageOptions = $this->makeMessageOptions($messageOptions);
334
335
        $sendResult = $this->sessionHandler->sendMessage(
336
            $msgName,
337
            $this->requestCreator->createRequest(
338
                $msgName,
339
                $options
340
            ),
341
            $messageOptions
342
        );
343
344
        return $this->responseHandler->analyzeResponse(
345
            $sendResult,
346
            $msgName
347
        );
348
    }
349
350
    /**
351
     * PNR_RetrieveAndDisplay - Retrieve an Amadeus PNR by record locator including extra info
352
     *
353
     * This extra info is info you cannot see in the regular PNR, like Offers.
354
     *
355
     * By default, the result will be the PNR_RetrieveAndDisplayReply XML as string.
356
     * That way you can easily parse the PNR's contents with XPath.
357
     *
358
     * Set $messageOptions['asString'] = FALSE to get the response as a PHP object.
359
     *
360
     * https://webservices.amadeus.com/extranet/viewService.do?id=1922&flavourId=1&menuId=functional
361
     *
362
     * @param RequestOptions\PnrRetrieveAndDisplayOptions $options Amadeus Record Locator for PNR
363
     * @param array $messageOptions (OPTIONAL) Set ['asString'] = 'false' to get PNR_RetrieveAndDisplayReply as a PHP object.
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
364
     * @return Result
365
     * @throws Exception
366
     **/
367 View Code Duplication
    public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
368
    {
369
        $msgName = 'PNR_RetrieveAndDisplay';
370
        $messageOptions = $this->makeMessageOptions($messageOptions);
371
372
        $sendResult = $this->sessionHandler->sendMessage(
373
            $msgName,
374
            $this->requestCreator->createRequest(
375
                $msgName,
376
                $options
377
            ),
378
            $messageOptions
379
        );
380
381
        return $this->responseHandler->analyzeResponse(
382
            $sendResult,
383
            $msgName
384
        );
385
    }
386
387
    /**
388
     * PNR_Cancel
389
     *
390
     * @param RequestOptions\PnrCancelOptions $options
391
     * @param array $messageOptions
392
     * @return Result
393
     */
394 View Code Duplication
    public function pnrCancel(RequestOptions\PnrCancelOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
395
    {
396
        $msgName = 'PNR_Cancel';
397
        $messageOptions = $this->makeMessageOptions($messageOptions);
398
399
        $sendResult = $this->sessionHandler->sendMessage(
400
            $msgName,
401
            $this->requestCreator->createRequest(
402
                $msgName,
403
                $options
404
            ),
405
            $messageOptions
406
        );
407
408
        return $this->responseHandler->analyzeResponse(
409
            $sendResult,
410
            $msgName
411
        );
412
    }
413
414
    /**
415
     * Queue_List - get a list of all PNR's on a given queue
416
     *
417
     * https://webservices.amadeus.com/extranet/viewService.do?id=52&flavourId=1&menuId=functional
418
     *
419
     * @param RequestOptions\QueueListOptions $options
420
     * @param array $messageOptions
421
     * @return Result
422
     */
423 View Code Duplication
    public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
424
    {
425
        $msgName = 'Queue_List';
426
        $messageOptions = $this->makeMessageOptions($messageOptions);
427
428
        $sendResult = $this->sessionHandler->sendMessage(
429
            $msgName,
430
            $this->requestCreator->createRequest(
431
                $msgName,
432
                $options
433
            ),
434
            $messageOptions
435
        );
436
437
        return $this->responseHandler->analyzeResponse(
438
            $sendResult,
439
            $msgName
440
        );
441
    }
442
443
    /**
444
     * Queue_PlacePNR - Place a PNR on a given queue
445
     *
446
     * @param RequestOptions\QueuePlacePnrOptions $options
447
     * @param array $messageOptions
448
     * @return Result
449
     */
450 View Code Duplication
    public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
451
    {
452
        $msgName = 'Queue_PlacePNR';
453
        $messageOptions = $this->makeMessageOptions($messageOptions);
454
455
        $sendResult = $this->sessionHandler->sendMessage(
456
            $msgName,
457
            $this->requestCreator->createRequest(
458
                $msgName,
459
                $options
460
            ),
461
            $messageOptions
462
        );
463
464
        return $this->responseHandler->analyzeResponse(
465
            $sendResult,
466
            $msgName
467
        );
468
    }
469
470
    /**
471
     * Queue_RemoveItem - remove an item (a PNR) from a given queue
472
     *
473
     * @param RequestOptions\QueueRemoveItemOptions $options
474
     * @param array $messageOptions
475
     * @return Result
476
     */
477 View Code Duplication
    public function queueRemoveItem(RequestOptions\QueueRemoveItemOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
478
    {
479
        $msgName = 'Queue_RemoveItem';
480
        $messageOptions = $this->makeMessageOptions($messageOptions);
481
482
        $sendResult = $this->sessionHandler->sendMessage(
483
            $msgName,
484
            $this->requestCreator->createRequest(
485
                $msgName,
486
                $options
487
            ),
488
            $messageOptions
489
        );
490
491
        return $this->responseHandler->analyzeResponse(
492
            $sendResult,
493
            $msgName
494
        );
495
    }
496
497
    /**
498
     * Queue_MoveItem - move an item (a PNR) from one queue to another.
499
     *
500
     * @param RequestOptions\QueueMoveItemOptions $options
501
     * @param array $messageOptions
502
     * @return Result
503
     */
504 View Code Duplication
    public function queueMoveItem(RequestOptions\QueueMoveItemOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
505
    {
506
        $msgName = 'Queue_MoveItem';
507
        $messageOptions = $this->makeMessageOptions($messageOptions);
508
509
        $sendResult = $this->sessionHandler->sendMessage(
510
            $msgName,
511
            $this->requestCreator->createRequest(
512
                $msgName,
513
                $options
514
            ),
515
            $messageOptions
516
        );
517
518
        return $this->responseHandler->analyzeResponse(
519
            $sendResult,
520
            $msgName
521
        );
522
    }
523
524
    /**
525
     * Offer_VerifyOffer
526
     *
527
     * To be called in the context of an open PNR
528
     *
529
     * @param RequestOptions\OfferVerifyOptions $options
530
     * @param array $messageOptions
531
     * @return Result
532
     */
533 View Code Duplication
    public function offerVerify(RequestOptions\OfferVerifyOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
534
    {
535
        $msgName = 'Offer_VerifyOffer';
536
        $messageOptions = $this->makeMessageOptions($messageOptions);
537
538
        $sendResult = $this->sessionHandler->sendMessage(
539
            $msgName,
540
            $this->requestCreator->createRequest(
541
                $msgName,
542
                $options
543
            ),
544
            $messageOptions
545
        );
546
547
        return $this->responseHandler->analyzeResponse(
548
            $sendResult,
549
            $msgName
550
        );
551
    }
552
553
    /**
554
     * Offer_ConfirmAirOffer
555
     *
556
     * @param RequestOptions\OfferConfirmAirOptions $options
557
     * @param array $messageOptions
558
     * @return Result
559
     */
560 View Code Duplication
    public function offerConfirmAir(RequestOptions\OfferConfirmAirOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
561
    {
562
        $msgName = 'Offer_ConfirmAirOffer';
563
        $messageOptions = $this->makeMessageOptions($messageOptions);
564
565
        $sendResult = $this->sessionHandler->sendMessage(
566
            $msgName,
567
            $this->requestCreator->createRequest(
568
                $msgName,
569
                $options
570
            ),
571
            $messageOptions
572
        );
573
574
        return $this->responseHandler->analyzeResponse(
575
            $sendResult,
576
            $msgName
577
        );
578
    }
579
580
    /**
581
     * Offer_ConfirmHotelOffer
582
     *
583
     * @param RequestOptions\OfferConfirmHotelOptions $options
584
     * @param array $messageOptions
585
     * @return Result
586
     */
587 View Code Duplication
    public function offerConfirmHotel(RequestOptions\OfferConfirmHotelOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
588
    {
589
        $msgName = 'Offer_ConfirmHotelOffer';
590
        $messageOptions = $this->makeMessageOptions($messageOptions);
591
592
        $sendResult = $this->sessionHandler->sendMessage(
593
            $msgName,
594
            $this->requestCreator->createRequest(
595
                $msgName,
596
                $options
597
            ),
598
            $messageOptions
599
        );
600
601
        return $this->responseHandler->analyzeResponse(
602
            $sendResult,
603
            $msgName
604
        );
605
    }
606
607
    /**
608
     * Offer_ConfirmCarOffer
609
     *
610
     * @param RequestOptions\OfferConfirmCarOptions $options
611
     * @param array $messageOptions
612
     * @return Result
613
     */
614 View Code Duplication
    public function offerConfirmCar(RequestOptions\OfferConfirmCarOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
615
    {
616
        $msgName = 'Offer_ConfirmCarOffer';
617
        $messageOptions = $this->makeMessageOptions($messageOptions);
618
619
        $sendResult = $this->sessionHandler->sendMessage(
620
            $msgName,
621
            $this->requestCreator->createRequest(
622
                $msgName,
623
                $options
624
            ),
625
            $messageOptions
626
        );
627
628
        return $this->responseHandler->analyzeResponse(
629
            $sendResult,
630
            $msgName
631
        );
632
    }
633
634
    /**
635
     * Fare_MasterPricerTravelBoardSearch
636
     *
637
     * @param RequestOptions\FareMasterPricerTbSearch $options
638
     * @param array $messageOptions
639
     * @return Result
640
     */
641 View Code Duplication
    public function fareMasterPricerTravelBoardSearch(RequestOptions\FareMasterPricerTbSearch $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
642
    {
643
        $msgName = 'Fare_MasterPricerTravelBoardSearch';
644
        $messageOptions = $this->makeMessageOptions($messageOptions);
645
646
        $sendResult = $this->sessionHandler->sendMessage(
647
            $msgName,
648
            $this->requestCreator->createRequest(
649
                $msgName,
650
                $options
651
            ),
652
            $messageOptions
653
        );
654
655
        return $this->responseHandler->analyzeResponse(
656
            $sendResult,
657
            $msgName
658
        );
659
    }
660
661
    /**
662
     * Fare_PricePnrWithBookingClass
663
     *
664
     * @param RequestOptions\FarePricePnrWithBookingClassOptions $options
665
     * @param array $messageOptions
666
     * @return Result
667
     */
668 View Code Duplication
    public function farePricePnrWithBookingClass(RequestOptions\FarePricePnrWithBookingClassOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 131 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
669
    {
670
        $msgName = 'Fare_PricePNRWithBookingClass';
671
        $messageOptions = $this->makeMessageOptions($messageOptions);
672
673
        $sendResult = $this->sessionHandler->sendMessage(
674
            $msgName,
675
            $this->requestCreator->createRequest(
676
                $msgName,
677
                $options
678
            ),
679
            $messageOptions
680
        );
681
682
        return $this->responseHandler->analyzeResponse(
683
            $sendResult,
684
            $msgName
685
        );
686
    }
687
688
    /**
689
     * Fare_CheckRules
690
     *
691
     * @param RequestOptions\FareCheckRulesOptions $options
692
     * @param array $messageOptions
693
     * @return Result
694
     */
695 View Code Duplication
    public function fareCheckRules(RequestOptions\FareCheckRulesOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
696
    {
697
        $msgName = 'Fare_CheckRules';
698
        $messageOptions = $this->makeMessageOptions($messageOptions);
699
700
        $sendResult = $this->sessionHandler->sendMessage(
701
            $msgName,
702
            $this->requestCreator->createRequest(
703
                $msgName,
704
                $options
705
            ),
706
            $messageOptions
707
        );
708
709
        return $this->responseHandler->analyzeResponse(
710
            $sendResult,
711
            $msgName
712
        );
713
    }
714
715
    /**
716
     * Fare_ConvertCurrency
717
     *
718
     * @param RequestOptions\FareConvertCurrencyOptions $options
719
     * @param array $messageOptions
720
     * @return Result
721
     */
722 View Code Duplication
    public function fareConvertCurrency(RequestOptions\FareConvertCurrencyOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
723
    {
724
        $msgName = 'Fare_ConvertCurrency';
725
        $messageOptions = $this->makeMessageOptions($messageOptions);
726
727
        $sendResult = $this->sessionHandler->sendMessage(
728
            $msgName,
729
            $this->requestCreator->createRequest(
730
                $msgName,
731
                $options
732
            ),
733
            $messageOptions
734
        );
735
736
        return $this->responseHandler->analyzeResponse(
737
            $sendResult,
738
            $msgName
739
        );
740
    }
741
742
    /**
743
     * Air_SellFromRecommendation
744
     *
745
     * @param RequestOptions\AirSellFromRecommendationOptions $options
746
     * @param array $messageOptions
747
     * @return Result
748
     */
749 View Code Duplication
    public function airSellFromRecommendation(RequestOptions\AirSellFromRecommendationOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
750
    {
751
        $msgName = 'Air_SellFromRecommendation';
752
        $messageOptions = $this->makeMessageOptions($messageOptions);
753
754
        $sendResult = $this->sessionHandler->sendMessage(
755
            $msgName,
756
            $this->requestCreator->createRequest(
757
                $msgName,
758
                $options
759
            ),
760
            $messageOptions
761
        );
762
763
        return $this->responseHandler->analyzeResponse(
764
            $sendResult,
765
            $msgName
766
        );
767
    }
768
769
    /**
770
     * Air_FlightInfo
771
     *
772
     * @param RequestOptions\AirFlightInfoOptions $options
773
     * @param array $messageOptions
774
     * @return Result
775
     */
776 View Code Duplication
    public function airFlightInfo(RequestOptions\AirFlightInfoOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
777
    {
778
        $msgName = 'Air_FlightInfo';
779
        $messageOptions = $this->makeMessageOptions($messageOptions);
780
781
        $sendResult = $this->sessionHandler->sendMessage(
782
            $msgName,
783
            $this->requestCreator->createRequest(
784
                $msgName,
785
                $options
786
            ),
787
            $messageOptions
788
        );
789
790
        return $this->responseHandler->analyzeResponse(
791
            $sendResult,
792
            $msgName
793
        );
794
    }
795
796
    /**
797
     * Air_RetrieveSeatMap
798
     *
799
     * @param RequestOptions\AirRetrieveSeatMapOptions $options
800
     * @param array $messageOptions
801
     * @return Result
802
     */
803 View Code Duplication
    public function airRetrieveSeatMap(RequestOptions\AirRetrieveSeatMapOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
804
    {
805
        $msgName = 'Air_RetrieveSeatMap';
806
        $messageOptions = $this->makeMessageOptions($messageOptions);
807
808
        $sendResult = $this->sessionHandler->sendMessage(
809
            $msgName,
810
            $this->requestCreator->createRequest(
811
                $msgName,
812
                $options
813
            ),
814
            $messageOptions
815
        );
816
817
        return $this->responseHandler->analyzeResponse(
818
            $sendResult,
819
            $msgName
820
        );
821
    }
822
823
    /**
824
     * Command_Cryptic
825
     *
826
     * @param RequestOptions\CommandCrypticOptions $options
827
     * @param array $messageOptions
828
     * @return Result
829
     */
830 View Code Duplication
    public function commandCryptic(RequestOptions\CommandCrypticOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
831
    {
832
        $msgName = 'Command_Cryptic';
833
        $messageOptions = $this->makeMessageOptions($messageOptions);
834
835
        $sendResult = $this->sessionHandler->sendMessage(
836
            $msgName,
837
            $this->requestCreator->createRequest(
838
                $msgName,
839
                $options
840
            ),
841
            $messageOptions
842
        );
843
844
        return $this->responseHandler->analyzeResponse(
845
            $sendResult,
846
            $msgName
847
        );
848
    }
849
850
    /**
851
     * MiniRule_GetFromPricingRec
852
     *
853
     * @param RequestOptions\MiniRuleGetFromPricingRecOptions $options
854
     * @param array $messageOptions
855
     * @return Result
856
     */
857 View Code Duplication
    public function miniRuleGetFromPricingRec(RequestOptions\MiniRuleGetFromPricingRecOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
858
    {
859
        $msgName = 'MiniRule_GetFromPricingRec';
860
        $messageOptions = $this->makeMessageOptions($messageOptions);
861
862
        $sendResult = $this->sessionHandler->sendMessage(
863
            $msgName,
864
            $this->requestCreator->createRequest(
865
                $msgName,
866
                $options
867
            ),
868
            $messageOptions
869
        );
870
871
        return $this->responseHandler->analyzeResponse(
872
            $sendResult,
873
            $msgName
874
        );
875
    }
876
877
    /**
878
     * Info_EncodeDecodeCity
879
     *
880
     * @param RequestOptions\InfoEncodeDecodeCityOptions $options
881
     * @param array $messageOptions
882
     * @return Result
883
     */
884 View Code Duplication
    public function infoEncodeDecodeCity(RequestOptions\InfoEncodeDecodeCityOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
885
    {
886
        $msgName = 'Info_EncodeDecodeCity';
887
        $messageOptions = $this->makeMessageOptions($messageOptions);
888
889
        $sendResult = $this->sessionHandler->sendMessage(
890
            $msgName,
891
            $this->requestCreator->createRequest(
892
                $msgName,
893
                $options
894
            ),
895
            $messageOptions
896
        );
897
898
        return $this->responseHandler->analyzeResponse(
899
            $sendResult,
900
            $msgName
901
        );
902
    }
903
904
905
    /**
906
     * Ticket_CreateTSTFromPricing
907
     *
908
     * @param RequestOptions\TicketCreateTstFromPricingOptions $options
909
     * @param array $messageOptions
910
     * @return Result
911
     */
912 View Code Duplication
    public function ticketCreateTSTFromPricing(RequestOptions\TicketCreateTstFromPricingOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 127 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
913
    {
914
        $msgName = 'Ticket_CreateTSTFromPricing';
915
        $messageOptions = $this->makeMessageOptions($messageOptions);
916
917
        $sendResult = $this->sessionHandler->sendMessage(
918
            $msgName,
919
            $this->requestCreator->createRequest(
920
                $msgName,
921
                $options
922
            ),
923
            $messageOptions
924
        );
925
926
        return $this->responseHandler->analyzeResponse(
927
            $sendResult,
928
            $msgName
929
        );
930
    }
931
932
    /**
933
     * DocIssuance_IssueTicket
934
     *
935
     * @param RequestOptions\DocIssuanceIssueTicketOptions $options
936
     * @param array $messageOptions
937
     * @return Result
938
     */
939 View Code Duplication
    public function docIssuanceIssueTicket(RequestOptions\DocIssuanceIssueTicketOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
940
    {
941
        $msgName = 'DocIssuance_IssueTicket';
942
        $messageOptions = $this->makeMessageOptions($messageOptions);
943
944
        $sendResult = $this->sessionHandler->sendMessage(
945
            $msgName,
946
            $this->requestCreator->createRequest(
947
                $msgName,
948
                $options
949
            ),
950
            $messageOptions
951
        );
952
953
        return $this->responseHandler->analyzeResponse(
954
            $sendResult,
955
            $msgName
956
        );
957
    }
958
959
    /**
960
     * PriceXplorer_ExtremeSearch
961
     *
962
     * @param RequestOptions\PriceXplorerExtremeSearchOptions $options
963
     * @param array $messageOptions
964
     * @return Result
965
     */
966 View Code Duplication
    public function priceXplorerExtremeSearch(RequestOptions\PriceXplorerExtremeSearchOptions $options, $messageOptions = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
967
    {
968
        $msgName = 'PriceXplorer_ExtremeSearch';
969
        $messageOptions = $this->makeMessageOptions($messageOptions);
970
971
        $sendResult = $this->sessionHandler->sendMessage(
972
            $msgName,
973
            $this->requestCreator->createRequest(
974
                $msgName,
975
                $options
976
            ),
977
            $messageOptions
978
        );
979
980
        return $this->responseHandler->analyzeResponse(
981
            $sendResult,
982
            $msgName
983
        );
984
    }
985
986
    /**
987
     * Make message options
988
     *
989
     * Message options are meta options when sending a message to the amadeus web services
990
     * - (if stateful) should we end the current session after sending this call?
991
     * - do you want the response as a PHP object or as a string?
992
     * - ... ?
993
     *
994
     * @param array $incoming The Message options chosen by the caller - if any.
995
     * @param bool $endSession Switch if you want to terminate the current session after making the call.
996
     * @return array
997
     */
998
    protected function makeMessageOptions(array $incoming, $endSession = false)
999
    {
1000
        $options = [
1001
            'endSession' => $endSession
1002
        ];
1003
1004
        if (array_key_exists('endSession', $incoming)) {
1005
            $options['endSession'] = $incoming['endSession'];
1006
        }
1007
1008
        return $options;
1009
    }
1010
1011
    /**
1012
     * Load the session handler
1013
     *
1014
     * Either load the provided session handler or create one depending on incoming parameters.
1015
     *
1016
     * @param HandlerInterface|null $sessionHandler
1017
     * @param Params\SessionHandlerParams $params
1018
     * @return HandlerInterface
1019
     */
1020
    protected function loadSessionHandler($sessionHandler, $params)
1021
    {
1022
        $newSessionHandler = null;
0 ignored issues
show
Unused Code introduced by
$newSessionHandler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1023
1024
        if ($sessionHandler instanceof HandlerInterface) {
1025
            $newSessionHandler = $sessionHandler;
1026
        } else {
1027
            $newSessionHandler = HandlerFactory::createHandler($params);
1028
        }
1029
1030
        return $newSessionHandler;
1031
    }
1032
1033
    /**
1034
     * Load a request creator
1035
     *
1036
     * A request creator is responsible for generating the correct request to send.
1037
     *
1038
     * @param RequestCreatorInterface|null $requestCreator
1039
     * @param Params\RequestCreatorParams $params
1040
     * @param string $libIdentifier Library identifier & version string (for Received From)
1041
     * @param string $originatorOffice The Office we are signed in with.
1042
     * @param array $mesVer Messages & Versions array of active messages in the WSDL
1043
     * @return RequestCreatorInterface
1044
     * @throws \RuntimeException
1045
     */
1046
    protected function loadRequestCreator($requestCreator, $params, $libIdentifier, $originatorOffice, $mesVer)
1047
    {
1048
        $newRequestCreator = null;
0 ignored issues
show
Unused Code introduced by
$newRequestCreator is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1049
1050
        if ($requestCreator instanceof RequestCreatorInterface) {
1051
            $newRequestCreator = $requestCreator;
1052
        } else {
1053
            $params->originatorOfficeId = $originatorOffice;
1054
            $params->messagesAndVersions = $mesVer;
1055
1056
            $newRequestCreator = RequestCreatorFactory::createRequestCreator(
1057
                $params,
1058
                $libIdentifier
1059
            );
1060
        }
1061
1062
        return $newRequestCreator;
1063
    }
1064
1065
    /**
1066
     * Load a response handler
1067
     *
1068
     * @param ResponseHandlerInterface|null $responseHandler
1069
     *
1070
     * @return ResponseHandlerInterface
1071
     * @throws \RuntimeException
1072
     */
1073
    protected function loadResponseHandler($responseHandler)
1074
    {
1075
        $newResponseHandler = null;
0 ignored issues
show
Unused Code introduced by
$newResponseHandler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1076
1077
        if ($responseHandler instanceof ResponseHandlerInterface) {
1078
            $newResponseHandler = $responseHandler;
1079
        } else {
1080
            $newResponseHandler = new ResponseHandlerBase();
1081
        }
1082
1083
        return $newResponseHandler;
1084
    }
1085
}
1086