Completed
Push — master ( 1d0975...18f0a3 )
by Dieter
08:30
created

Base::analyzeSecuritySignOutResponse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
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\ResponseHandler;
24
25
use Amadeus\Client\Exception;
26
use Amadeus\Client\ResponseHandler\Air\RetrieveSeatMap;
27
use Amadeus\Client\Result;
28
use Amadeus\Client\Session\Handler\SendResult;
29
30
/**
31
 * Default Response Handler
32
 *
33
 * Analyses the responses received from the Amadeus WS server and checks for error messages.
34
 * If errors are found, the error information will be extracted and the response status will be changed
35
 * accordingly.
36
 *
37
 * @package Amadeus\Client\ResponseHandler
38
 * @author Dieter Devlieghere <[email protected]>
39
 */
40
class Base extends BaseUtils
41
{
42
    /**
43
     * Analyze the response from the server and throw an exception when an error has been detected.
44
     *
45
     * @param SendResult $sendResult The Send Result from the Session Handler
46
     * @param string $messageName The message that was called
47
     *
48
     * @throws Exception
49
     * @throws \RuntimeException
50
     * @return Result
51
     */
52 77
    public function analyzeResponse($sendResult, $messageName)
53
    {
54 77
        $methodName = 'analyze'.str_replace('_', '', ucfirst($messageName)).'Response';
55
56 77
        if (!empty($sendResult->exception)) {
57 2
            return $this->makeResultForException($sendResult);
58 75
        } elseif (method_exists($this, $methodName)) {
59 74
            return $this->$methodName(
60
                $sendResult
61 74
            );
62
        } else {
63 1
            return new Result($sendResult, Result::STATUS_UNKNOWN);
64
        }
65
    }
66
67
    /**
68
     * Analysing a Security_Authenticate
69
     *
70
     * @param SendResult $response Security_Authenticate result
71
     * @return Result
72
     */
73 2
    protected function analyzeSecurityAuthenticateResponse($response)
74
    {
75 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
76
    }
77
78
    /**
79
     * Analysing a Security_Authenticate
80
     *
81
     * @param SendResult $response Security_Authenticate result
82
     * @return Result
83
     */
84 2
    protected function analyzeSecuritySignOutResponse($response)
85
    {
86 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
87
    }
88
89
    /**
90
     * Unknown response for Command_Cryptic because you need to analyse the cryptic response yourself
91
     *
92
     * @param SendResult $response
93
     * @return Result
94
     */
95 1
    protected function analyzeCommandCrypticResponse($response)
96
    {
97 1
        $ccResult = new Result($response, Result::STATUS_UNKNOWN);
98 1
        $ccResult->messages[] = new Result\NotOk(
99 1
            0,
100
            "Response handling not supported for cryptic entries"
101 1
        );
102
103 1
        return $ccResult;
104
    }
105
106 1 View Code Duplication
    protected function analyzeAirMultiAvailabilityResponse($response)
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...
107
    {
108 1
        $analyzeResponse = new Result($response);
109
110 1
        $message = null;
111
112 1
        $domXpath = $this->makeDomXpath($response->responseXml);
113
114 1
        $codeNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:code")->item(0);
115 1
        if ($codeNode instanceof \DOMNode) {
116 1
            $analyzeResponse->status = Result::STATUS_ERROR;
117
118 1
            $categoryNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:type")->item(0);
119 1
            if ($categoryNode instanceof \DOMNode) {
120 1
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
121 1
            }
122
123 1
            $messageNodes = $domXpath->query('//m:errorOrWarningSection/m:textInformation/m:freeText');
124 1
            if ($messageNodes->length > 0) {
125 1
                $message = $this->makeMessageFromMessagesNodeList($messageNodes);
126 1
            }
127 1
            $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message);
128 1
        }
129
130 1
        return $analyzeResponse;
131
    }
132
133 2
    protected function analyzeAirSellFromRecommendationResponse($response)
134
    {
135 2
        $analyzeResponse = new Result($response);
136
137
        $errMsgMap = [
138 2
            "288" => "UNABLE TO SATISFY, NEED CONFIRMED FLIGHT STATUS",
139
            "390" => "UNABLE TO REFORMAT"
140 2
        ];
141
142 2
        $domXpath = $this->makeDomXpath($response->responseXml);
143
144 2
        $codeNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCode")->item(0);
145 2
        if ($codeNode instanceof \DOMNode) {
146 2
            $analyzeResponse->status = Result::STATUS_ERROR;
147
148 2
            $categoryNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCategory")->item(0);
149 2
            if ($categoryNode instanceof \DOMNode) {
150 2
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
151 2
            }
152
153 2
            $message = (array_key_exists($codeNode->nodeValue, $errMsgMap)) ?
154 2
                $errMsgMap[$codeNode->nodeValue] : 'UNKNOWN ERROR';
155
156 2
            $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message);
157 2
        }
158
159 2
        return $analyzeResponse;
160
    }
161
162
    /**
163
     * @param SendResult $response
164
     * @return Result
165
     */
166 1
    protected function analyzeAirFlightInfoResponse($response)
167
    {
168 1
        $analyzeResponse = new Result($response);
169
170 1
        $code = null;
171 1
        $message = null;
172
173 1
        $domXpath = $this->makeDomXpath($response->responseXml);
174
175 1
        $categoryNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCategory');
176 1
        if ($categoryNodes->length > 0) {
177 1
            $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNodes->item(0)->nodeValue);
178 1
        }
179
180 1
        $codeNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCode');
181 1
        if ($codeNodes->length > 0) {
182 1
            $code = $codeNodes->item(0)->nodeValue;
183 1
        }
184
185 1
        $messageNodes = $domXpath->query('//m:responseError/m:interactiveFreeText/m:freeText');
186 1
        if ($messageNodes->length > 0) {
187 1
            $message = $this->makeMessageFromMessagesNodeList($messageNodes);
188 1
        }
189
190 1
        if (!is_null($message) && !is_null($code)) {
191 1
            $analyzeResponse->messages[] = new Result\NotOk($code, $message);
192 1
        }
193
194 1
        return $analyzeResponse;
195
    }
196
197
    /**
198
     * @param SendResult $response
199
     * @return Result
200
     */
201 6
    protected function analyzeAirRetrieveSeatMapResponse($response)
202
    {
203 6
        $analyzeResponse = new Result($response);
204
205 6
        $domXpath = $this->makeDomXpath($response->responseXml);
206
207 6
        $errorCodeNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:code');
208 6 View Code Duplication
        if ($errorCodeNode->length > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
209 3
            $analyzeResponse->status = Result::STATUS_ERROR;
210
211 3
            $errCode = $errorCodeNode->item(0)->nodeValue;
212 3
            $level = null;
213
214 3
            $errorLevelNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:processingLevel');
215 3
            if ($errorLevelNode->length > 0) {
216 3
                $level = RetrieveSeatMap::decodeProcessingLevel($errorLevelNode->item(0)->nodeValue);
217 3
            }
218
219 3
            $errorDescNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:description');
220 3
            if ($errorDescNode->length > 0) {
221 1
                $errDesc = $errorDescNode->item(0)->nodeValue;
222 1
            } else {
223 2
                $errDesc = RetrieveSeatMap::findMessage($errCode);
224
            }
225
226 3
            $analyzeResponse->messages[] = new Result\NotOk(
227 3
                $errCode,
228 3
                $errDesc,
229
                $level
230 3
            );
231 3
        }
232
233 6
        $codeNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:number');
234 6 View Code Duplication
        if ($codeNode->length > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
235 2
            $analyzeResponse->status = Result::STATUS_WARN;
236
237 2
            $warnCode = $codeNode->item(0)->nodeValue;
238 2
            $level = null;
239
240 2
            $levelNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:processingLevel');
241 2
            if ($levelNode->length > 0) {
242 2
                $level = RetrieveSeatMap::decodeProcessingLevel($levelNode->item(0)->nodeValue);
243 2
            }
244
245 2
            $descNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:description');
246 2
            if ($descNode->length > 0) {
247 1
                $warnDesc = $descNode->item(0)->nodeValue;
248 1
            } else {
249 1
                $warnDesc = RetrieveSeatMap::findMessage($warnCode);
250
            }
251
252 2
            $analyzeResponse->messages[] = new Result\NotOk(
253 2
                $warnCode,
254 2
                $warnDesc,
255
                $level
256 2
            );
257 2
        }
258
259 6
        return $analyzeResponse;
260
    }
261
262
    /**
263
     * Analysing a PNR_Retrieve response
264
     *
265
     * @param SendResult $response PNR_Retrieve result
266
     * @return Result
267
     */
268 1
    protected function analyzePnrRetrieveResponse($response)
269
    {
270 1
        return $this->analyzePnrReply($response);
271
    }
272
273
    /**
274
     * @param SendResult $response PNR_AddMultiElements result
275
     * @return Result
276
     */
277 4
    protected function analyzePnrAddMultiElementsResponse($response)
278
    {
279 4
        return $this->analyzePnrReply($response);
280
    }
281
282
    /**
283
     * @param SendResult $response PNR_Cancel result
284
     * @return Result
285
     */
286 1
    protected function analyzePnrCancelResponse($response)
287
    {
288 1
        return $this->analyzePnrReply($response);
289
    }
290
291
    /**
292
     * @param SendResult $response Pnr_RetrieveAndDisplay response
293
     * @return Result
294
     * @throws Exception
295
     */
296 2
    protected function analyzePnrRetrieveAndDisplayResponse($response)
297
    {
298 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
299
    }
300
301
    /**
302
     * Analysing a PNR_TransferOwnershipReply
303
     *
304
     * @param SendResult $response PNR_TransferOwnership response
305
     * @return Result
306
     * @throws Exception
307
     */
308 2
    protected function analyzePNRTransferOwnershipResponse($response)
309
    {
310 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
311
    }
312
313
    /**
314
     * Analysing a PNR_DisplayHistoryReply
315
     *
316
     * @param SendResult $response PNR_DisplayHistoryReply result
317
     * @return Result
318
     * @throws Exception
319
     */
320 2
    protected function analyzePnrDisplayHistoryResponse($response)
321
    {
322 2
        $analyzeResponse = new Result($response);
323
324 2
        $domXpath = $this->makeDomXpath($response->responseXml);
325
326 2
        $queryAllErrorCodes = "//m:generalErrorGroup//m:errorNumber/m:errorDetails/m:errorCode";
327 2
        $queryAllErrorMsg = "//m:generalErrorGroup/m:genrealErrorText/m:freeText";
328
329 2
        $errorCodeNodeList = $domXpath->query($queryAllErrorCodes);
330
331 2 View Code Duplication
        if ($errorCodeNodeList->length > 0) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
332 1
            $analyzeResponse->status = Result::STATUS_ERROR;
333
334 1
            $code = $errorCodeNodeList->item(0)->nodeValue;
335 1
            $errorTextNodeList = $domXpath->query($queryAllErrorMsg);
336 1
            $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
337
338 1
            $analyzeResponse->messages[] = new Result\NotOk($code, trim($message));
339 1
        }
340
341 2
        return $analyzeResponse;
342
    }
343
344
    /**
345
     * @param SendResult $response Queue_RemoveItem response
346
     * @return Result
347
     * @throws Exception
348
     */
349 1
    protected function analyzeQueueRemoveItemResponse($response)
350
    {
351 1
        return $this->analyzeGenericQueueResponse($response);
352
    }
353
354
    /**
355
     * @param SendResult $response Queue_MoveItem response
356
     * @return Result
357
     * @throws Exception
358
     */
359 2
    protected function analyzeQueueMoveItemResponse($response)
360
    {
361 2
        return $this->analyzeGenericQueueResponse($response);
362
    }
363
364
    /**
365
     * @param SendResult $response Queue_PlacePNR response
366
     * @return Result
367
     * @throws Exception
368
     */
369 1
    protected function analyzeQueuePlacePNRResponse($response)
370
    {
371 1
        return $this->analyzeGenericQueueResponse($response);
372
    }
373
374
    /**
375
     * @param SendResult $response Queue_List result
376
     * @return Result
377
     * @throws Exception
378
     */
379 2
    protected function analyzeQueueListResponse($response)
380
    {
381 2
        return $this->analyzeGenericQueueResponse($response);
382
    }
383
384
    /**
385
     * Analyze a generic Queue response
386
     *
387
     * @param SendResult $response Queue_*Reply result
388
     * @return Result
389
     * @throws Exception
390
     */
391 6
    protected function analyzeGenericQueueResponse($response)
392
    {
393 6
        $analysisResponse = new Result($response);
394
395 6
        $domDoc = $this->loadDomDocument($response->responseXml);
396
397 6
        $errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0);
398
399 6
        if (!is_null($errorCodeNode)) {
400 3
            $analysisResponse->status = Result::STATUS_WARN;
401
402 3
            $errorCode = $errorCodeNode->nodeValue;
403 3
            $errorMessage = $this->getErrorTextFromQueueErrorCode($errorCode);
404
405 3
            $analysisResponse->messages[] = new Result\NotOk($errorCode, $errorMessage);
406 3
        }
407
408 6
        return $analysisResponse;
409
    }
410
411
412
    /**
413
     * @param SendResult $response Fare_PricePNRWithBookingClass result
414
     * @return Result
415
     * @throws Exception
416
     */
417 8 View Code Duplication
    protected function analyzeFarePricePNRWithBookingClassResponse($response)
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...
418
    {
419 8
        $analyzeResponse = new Result($response);
420
421 8
        $domXpath = $this->makeDomXpath($response->responseXml);
422
423 7
        $queryErrorCode = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode";
424 7
        $queryErrorCategory = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory";
425 7
        $queryErrorMsg = "//m:applicationError/m:errorWarningDescription/m:freeText";
426
427 7
        $errorCodeNodeList = $domXpath->query($queryErrorCode);
428
429 7
        if ($errorCodeNodeList->length > 0) {
430 4
            $analyzeResponse->status = Result::STATUS_ERROR;
431
432 4
            $errorCatNode = $domXpath->query($queryErrorCategory)->item(0);
433 4
            if ($errorCatNode instanceof \DOMNode) {
434 4
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
435 4
            }
436
437 4
            $analyzeResponse->messages[] = new Result\NotOk(
438 4
                $errorCodeNodeList->item(0)->nodeValue,
439 4
                $this->makeMessageFromMessagesNodeList(
440 4
                    $domXpath->query($queryErrorMsg)
441 4
                )
442 4
            );
443 4
        }
444
445 7
        return $analyzeResponse;
446
    }
447
448
    /**
449
     * @param SendResult $response Fare_PricePNRWithLowerFares result
450
     * @return Result
451
     * @throws Exception
452
     */
453 2
    protected function analyzeFarePricePNRWithLowerFaresResponse($response)
454
    {
455 2
        return $this->analyzeFarePricePNRWithBookingClassResponse($response);
456
    }
457
458
    /**
459
     * @param SendResult $response Fare_PricePNRWithLowestFare result
460
     * @return Result
461
     * @throws Exception
462
     */
463 2
    protected function analyzeFarePricePNRWithLowestFareResponse($response)
464
    {
465 2
        return $this->analyzeFarePricePNRWithBookingClassResponse($response);
466
    }
467
468
    /**
469
     * @param SendResult $response
470
     * @return Result
471
     */
472 1
    protected function analyzeFareMasterPricerCalendarResponse($response)
473
    {
474 1
        return $this->analyzeFareMasterPricerTravelBoardSearchResponse($response);
475
    }
476
477
    /**
478
     * @param SendResult $response
479
     * @return Result
480
     */
481 2
    protected function analyzeFareMasterPricerTravelBoardSearchResponse($response)
482
    {
483 2
        $analyzeResponse = new Result($response);
484
485 2
        $domXpath = $this->makeDomXpath($response->responseXml);
486
487 2
        $queryErrCode = "//m:applicationError//m:applicationErrorDetail/m:error";
488 2
        $queryErrMsg = "//m:errorMessageText/m:description";
489
490 2
        $codeNode = $domXpath->query($queryErrCode)->item(0);
491
492 2
        if ($codeNode instanceof \DOMNode) {
493 2
            $analyzeResponse->status = Result::STATUS_ERROR;
494
495 2
            $errMsg = '';
496 2
            $errMsgNode = $domXpath->query($queryErrMsg)->item(0);
497 2
            if ($errMsgNode instanceof \DOMNode) {
498 2
                $errMsg = $errMsgNode->nodeValue;
499 2
            }
500
501 2
            $analyzeResponse->messages[] = new Result\NotOk(
502 2
                $codeNode->nodeValue,
503
                $errMsg
504 2
            );
505 2
        }
506
507 2
        return $analyzeResponse;
508
    }
509
510
    /**
511
     * @param SendResult $response
512
     * @return Result
513
     */
514 1
    protected function analyzeFareConvertCurrencyResponse($response)
515
    {
516 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
517
    }
518
519
    /**
520
     * @param SendResult $response
521
     * @return Result
522
     */
523 1
    protected function analyzeFareCheckRulesResponse($response)
524
    {
525 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
526
    }
527
528
    /**
529
     * @param SendResult $response
530
     * @return Result
531
     */
532 2
    protected function analyzeFareInformativePricingWithoutPNRResponse($response)
533
    {
534 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
535
    }
536
537
    /**
538
     * @param SendResult $response
539
     * @return Result
540
     */
541 2
    protected function analyzeFareInformativeBestPricingWithoutPNRResponse($response)
542
    {
543 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
544
    }
545
546
    /**
547
     * DocIssuance_IssueTicket
548
     *
549
     * @param SendResult $response
550
     * @return Result
551
     */
552 2
    protected function analyzeDocIssuanceIssueTicketResponse($response)
553
    {
554 2
        return $this->analyzeSimpleResponseErrorCodeAndMessageStatusCode($response);
555
    }
556
557
    /**
558
     * DocIssuance_IssueMiscellaneousDocuments
559
     *
560
     * @param SendResult $response
561
     * @return Result
562
     */
563 1
    protected function analyzeDocIssuanceIssueMiscellaneousDocumentsResponse($response)
564
    {
565 1
        return $this->analyzeSimpleResponseErrorCodeAndMessageStatusCode($response);
566
    }
567
568
    /**
569
     * @param SendResult $response Ticket_DeleteTST result
570
     * @return Result
571
     */
572 1
    protected function analyzeTicketDisplayTSTResponse($response)
573
    {
574 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
575
    }
576
577
    /**
578
     * @param SendResult $response Ticket_DeleteTST result
579
     * @return Result
580
     */
581 1
    protected function analyzeTicketDeleteTSTResponse($response)
582
    {
583 1
        return $this->analyzeTicketCreateTSTFromPricingResponse($response);
584
    }
585
586
    /**
587
     * @param SendResult $response Ticket_DeleteTSMP result
588
     * @return Result
589
     */
590 1
    protected function analyzeTicketDeleteTSMPResponse($response)
591
    {
592 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
593
    }
594
595
    /**
596
     * @param SendResult $response Ticket_CreateTSTFromPricing result
597
     * @return Result
598
     */
599 3 View Code Duplication
    protected function analyzeTicketCreateTSTFromPricingResponse($response)
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...
600
    {
601 3
        $analyzeResponse = new Result($response);
602
603 3
        $domDoc = $this->loadDomDocument($response->responseXml);
604
605 3
        $errorCodeNode = $domDoc->getElementsByTagName("applicationErrorCode")->item(0);
606
607 3
        if (!is_null($errorCodeNode)) {
608 3
            $analyzeResponse->status = Result::STATUS_ERROR;
609
610 3
            $errorCatNode = $domDoc->getElementsByTagName("codeListQualifier")->item(0);
611 3
            if ($errorCatNode instanceof \DOMNode) {
612 3
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
613 3
            }
614
615 3
            $errorCode = $errorCodeNode->nodeValue;
616 3
            $errorTextNodeList = $domDoc->getElementsByTagName("errorFreeText");
617
618 3
            $analyzeResponse->messages[] = new Result\NotOk(
619 3
                $errorCode,
620 3
                $this->makeMessageFromMessagesNodeList($errorTextNodeList)
621 3
            );
622 3
        }
623
624 3
        return $analyzeResponse;
625
    }
626
627
    /**
628
     * @param SendResult $response Ticket_CreateTSMFromPricing result
629
     * @return Result
630
     */
631 1
    protected function analyzeTicketCreateTSMFromPricingResponse($response)
632
    {
633 1
        return $this->analyzeTicketCreateTSTFromPricingResponse($response);
634
    }
635
636
    /**
637
     * @param SendResult $response
638
     * @return Result
639
     */
640 2
    protected function analyzeOfferConfirmCarOfferResponse($response)
641
    {
642 2
        return $this->analyzeGenericOfferResponse($response);
643
    }
644
645
    /**
646
     * @param SendResult $response
647
     * @return Result
648
     */
649 2
    protected function analyzeOfferConfirmHotelOfferResponse($response)
650
    {
651 2
        $analyzeResponse = new Result($response);
652
653 2
        $domXpath = $this->makeDomXpath($response->responseXml);
654
655 2
        $codeNode = $domXpath->query("//m:errorDetails/m:errorCode")->item(0);
656 2
        if ($codeNode instanceof \DOMNode) {
657 1
            $analyzeResponse->status = Result::STATUS_ERROR;
658
659 1
            $categoryNode = $domXpath->query("//m:errorDetails/m:errorCategory")->item(0);
660 1
            if ($categoryNode instanceof \DOMNode) {
661 1
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
662 1
            }
663
664 1
            $msgNode = $domXpath->query('//m:errorDescription/m:freeText')->item(0);
665
666 1
            $analyzeResponse->messages[] = new Result\NotOk(
667 1
                $codeNode->nodeValue,
668 1
                trim($msgNode->nodeValue)
669 1
            );
670 1
        }
671
672 2
        return $analyzeResponse;
673
    }
674
675
    /**
676
     * Offer_ConfirmAirOffer
677
     *
678
     * @param SendResult $response
679
     * @return Result
680
     */
681 2
    protected function analyzeOfferConfirmAirOfferResponse($response)
682
    {
683 2
        return $this->analyzeGenericOfferResponse($response);
684
    }
685
686
    /**
687
     * Offer_VerifyOffer
688
     *
689
     * @param SendResult $response
690
     * @return Result
691
     */
692 2
    protected function analyzeOfferVerifyOfferResponse($response)
693
    {
694 2
        return $this->analyzeGenericOfferResponse($response);
695
    }
696
697
    /**
698
     * Offer_CreateOffer
699
     *
700
     * @param SendResult $response
701
     * @return Result
702
     */
703 2
    protected function analyzeOfferCreateOfferResponse($response)
704
    {
705 2
        return $this->analyzeGenericOfferResponse($response);
706
    }
707
708
    /**
709
     * @param SendResult $response
710
     * @return Result
711
     */
712 2
    protected function analyzeMiniRuleGetFromPricingRecResponse($response)
713
    {
714 2
        $analyzeResponse = new Result($response);
715
716 2
        $domXpath = $this->makeDomXpath($response->responseXml);
717
718 2
        $statusNode = $domXpath->query('//m:responseDetails/m:statusCode')->item(0);
719 2
        if ($statusNode instanceof \DOMNode) {
720 2
            $code = $statusNode->nodeValue;
721
722 2
            if ($code !== 'O') {
723 2
                $categoryNode = $domXpath->query(
724
                    '//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory'
725 2
                )->item(0);
726 2
                $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue);
727
728 2
                $codeNode = $domXpath->query('//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode')->item(0);
729 2
                $msgNode = $domXpath->query('//m:errorWarningDescription/m:freeText')->item(0);
730
731 2
                if ($codeNode instanceof \DOMNode && $msgNode instanceof \DOMNode) {
732 2
                    $analyzeResponse->messages[] = new Result\NotOk(
733 2
                        $codeNode->nodeValue,
734 2
                        $msgNode->nodeValue
735 2
                    );
736 2
                }
737 2
            }
738 2
        }
739
740 2
        return $analyzeResponse;
741
    }
742
743
    /**
744
     * @param SendResult $response
745
     * @return Result
746
     */
747 1
    protected function analyzeMiniRuleGetFromPricingResponse($response)
748
    {
749 1
        return $this->analyzeMiniRuleGetFromPricingRecResponse($response);
750
    }
751
752
    /**
753
     * @param SendResult $response
754
     * @return Result
755
     */
756 1
    protected function analyzeInfoEncodeDecodeCityResponse($response)
757
    {
758 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
759
    }
760
761
    /**
762
     * @param SendResult $response
763
     * @return Result
764
     */
765 1
    protected function analyzePriceXplorerExtremeSearchResponse($response)
766
    {
767 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
768
    }
769
770
    /**
771
     * @param SendResult $response
772
     * @return Result
773
     */
774 1
    protected function analyzeSalesReportsDisplayQueryReportResponse($response)
775
    {
776 1
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
777
    }
778
779
    /**
780
     * @param SendResult $response
781
     * @return Result
782
     */
783 2
    protected function analyzeServiceIntegratedPricingResponse($response)
784
    {
785 2
        return $this->analyzeSimpleResponseErrorCodeAndMessage($response);
786
    }
787
}
788