Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Base often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Base, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 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 | public function analyzeResponse($sendResult, $messageName) |
||
| 53 | { |
||
| 54 | $methodName = 'analyze' . str_replace('_', '', ucfirst($messageName)) . 'Response'; |
||
| 55 | |||
| 56 | if (!empty($sendResult->exception)) { |
||
| 57 | return $this->makeResultForException($sendResult); |
||
| 58 | } elseif (method_exists($this, $methodName)) { |
||
| 59 | return $this->$methodName( |
||
| 60 | $sendResult |
||
| 61 | ); |
||
| 62 | } else { |
||
| 63 | 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 | protected function analyzeSecurityAuthenticateResponse($response) |
||
| 74 | { |
||
| 75 | 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 | protected function analyzeSecuritySignOutResponse($response) |
||
| 85 | { |
||
| 86 | 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 | protected function analyzeCommandCrypticResponse($response) |
||
| 96 | { |
||
| 97 | $ccResult = new Result($response, Result::STATUS_UNKNOWN); |
||
| 98 | $ccResult->messages[] = new Result\NotOk( |
||
| 99 | 0, |
||
| 100 | "Response handling not supported for cryptic entries" |
||
| 101 | ); |
||
| 102 | |||
| 103 | return $ccResult; |
||
| 104 | } |
||
| 105 | |||
| 106 | View Code Duplication | protected function analyzeAirMultiAvailabilityResponse($response) |
|
|
|
|||
| 107 | { |
||
| 108 | $analyzeResponse = new Result($response); |
||
| 109 | |||
| 110 | $message = null; |
||
| 111 | |||
| 112 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 113 | |||
| 114 | $codeNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:code")->item(0); |
||
| 115 | if ($codeNode instanceof \DOMNode) { |
||
| 116 | $analyzeResponse->status = Result::STATUS_ERROR; |
||
| 117 | |||
| 118 | $categoryNode = $domXpath->query("//m:errorOrWarningSection/m:errorOrWarningInfo//m:type")->item(0); |
||
| 119 | if ($categoryNode instanceof \DOMNode) { |
||
| 120 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
||
| 121 | } |
||
| 122 | |||
| 123 | $messageNodes = $domXpath->query('//m:errorOrWarningSection/m:textInformation/m:freeText'); |
||
| 124 | if ($messageNodes->length > 0) { |
||
| 125 | $message = $this->makeMessageFromMessagesNodeList($messageNodes); |
||
| 126 | } |
||
| 127 | $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message); |
||
| 128 | } |
||
| 129 | |||
| 130 | return $analyzeResponse; |
||
| 131 | } |
||
| 132 | |||
| 133 | protected function analyzeAirSellFromRecommendationResponse($response) |
||
| 134 | { |
||
| 135 | $analyzeResponse = new Result($response); |
||
| 136 | |||
| 137 | $errMsgMap = [ |
||
| 138 | "288" => "UNABLE TO SATISFY, NEED CONFIRMED FLIGHT STATUS", |
||
| 139 | "390" => "UNABLE TO REFORMAT" |
||
| 140 | ]; |
||
| 141 | |||
| 142 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 143 | |||
| 144 | $codeNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCode")->item(0); |
||
| 145 | if ($codeNode instanceof \DOMNode) { |
||
| 146 | $analyzeResponse->status = Result::STATUS_ERROR; |
||
| 147 | |||
| 148 | $categoryNode = $domXpath->query("//m:errorSegment/m:errorDetails/m:errorCategory")->item(0); |
||
| 149 | if ($categoryNode instanceof \DOMNode) { |
||
| 150 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
||
| 151 | } |
||
| 152 | |||
| 153 | $message = (array_key_exists($codeNode->nodeValue, $errMsgMap)) ? |
||
| 154 | $errMsgMap[$codeNode->nodeValue] : 'UNKNOWN ERROR'; |
||
| 155 | |||
| 156 | $analyzeResponse->messages [] = new Result\NotOk($codeNode->nodeValue, $message); |
||
| 157 | } |
||
| 158 | |||
| 159 | return $analyzeResponse; |
||
| 160 | } |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @param SendResult $response |
||
| 164 | * @return Result |
||
| 165 | */ |
||
| 166 | protected function analyzeAirFlightInfoResponse($response) |
||
| 167 | { |
||
| 168 | $analyzeResponse = new Result($response); |
||
| 169 | |||
| 170 | $code = null; |
||
| 171 | $message = null; |
||
| 172 | |||
| 173 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 174 | |||
| 175 | $categoryNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCategory'); |
||
| 176 | if ($categoryNodes->length > 0) { |
||
| 177 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNodes->item(0)->nodeValue); |
||
| 178 | } |
||
| 179 | |||
| 180 | $codeNodes = $domXpath->query('//m:responseError/m:errorInfo/m:errorDetails/m:errorCode'); |
||
| 181 | if ($codeNodes->length > 0) { |
||
| 182 | $code = $codeNodes->item(0)->nodeValue; |
||
| 183 | } |
||
| 184 | |||
| 185 | $messageNodes = $domXpath->query('//m:responseError/m:interactiveFreeText/m:freeText'); |
||
| 186 | if ($messageNodes->length > 0) { |
||
| 187 | $message = $this->makeMessageFromMessagesNodeList($messageNodes); |
||
| 188 | } |
||
| 189 | |||
| 190 | if (!is_null($message) && !is_null($code)) { |
||
| 191 | $analyzeResponse->messages[] = new Result\NotOk($code, $message); |
||
| 192 | } |
||
| 193 | |||
| 194 | return $analyzeResponse; |
||
| 195 | } |
||
| 196 | |||
| 197 | /** |
||
| 198 | * @param SendResult $response |
||
| 199 | * @return Result |
||
| 200 | */ |
||
| 201 | protected function analyzeAirRetrieveSeatMapResponse($response) |
||
| 202 | { |
||
| 203 | $analyzeResponse = new Result($response); |
||
| 204 | |||
| 205 | $code = null; |
||
| 206 | $message = null; |
||
| 207 | |||
| 208 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 209 | |||
| 210 | $errorCodeNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:code'); |
||
| 211 | View Code Duplication | if ($errorCodeNode->length > 0) { |
|
| 212 | $analyzeResponse->status = Result::STATUS_ERROR; |
||
| 213 | |||
| 214 | $errCode = $errorCodeNode->item(0)->nodeValue; |
||
| 215 | $level = null; |
||
| 216 | $errDesc = null; |
||
| 217 | |||
| 218 | $errorLevelNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:processingLevel'); |
||
| 219 | if ($errorLevelNode->length > 0) { |
||
| 220 | $level = RetrieveSeatMap::decodeProcessingLevel($errorLevelNode->item(0)->nodeValue); |
||
| 221 | } |
||
| 222 | |||
| 223 | $errorDescNode = $domXpath->query('//m:errorInformation/m:errorDetails/m:description'); |
||
| 224 | if ($errorDescNode->length > 0) { |
||
| 225 | $errDesc = $errorDescNode->item(0)->nodeValue; |
||
| 226 | } else { |
||
| 227 | $errDesc = RetrieveSeatMap::findMessage($errCode); |
||
| 228 | } |
||
| 229 | |||
| 230 | $analyzeResponse->messages[] = new Result\NotOk( |
||
| 231 | $errCode, |
||
| 232 | $errDesc, |
||
| 233 | $level |
||
| 234 | ); |
||
| 235 | } |
||
| 236 | |||
| 237 | $codeNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:number'); |
||
| 238 | View Code Duplication | if ($codeNode->length > 0) { |
|
| 239 | $analyzeResponse->status = Result::STATUS_WARN; |
||
| 240 | |||
| 241 | $warnCode = $codeNode->item(0)->nodeValue; |
||
| 242 | $level = null; |
||
| 243 | $warnDesc = null; |
||
| 244 | |||
| 245 | $levelNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:processingLevel'); |
||
| 246 | if ($levelNode->length > 0) { |
||
| 247 | $level = RetrieveSeatMap::decodeProcessingLevel($levelNode->item(0)->nodeValue); |
||
| 248 | } |
||
| 249 | |||
| 250 | $descNode = $domXpath->query('//m:warningInformation/m:warningDetails/m:description'); |
||
| 251 | if ($descNode->length > 0) { |
||
| 252 | $warnDesc = $descNode->item(0)->nodeValue; |
||
| 253 | } else { |
||
| 254 | $warnDesc = RetrieveSeatMap::findMessage($warnCode); |
||
| 255 | } |
||
| 256 | |||
| 257 | $analyzeResponse->messages[] = new Result\NotOk( |
||
| 258 | $warnCode, |
||
| 259 | $warnDesc, |
||
| 260 | $level |
||
| 261 | ); |
||
| 262 | } |
||
| 263 | |||
| 264 | return $analyzeResponse; |
||
| 265 | } |
||
| 266 | |||
| 267 | /** |
||
| 268 | * Analysing a PNR_Retrieve response |
||
| 269 | * |
||
| 270 | * @param SendResult $response PNR_Retrieve result |
||
| 271 | * @return Result |
||
| 272 | */ |
||
| 273 | protected function analyzePnrRetrieveResponse($response) |
||
| 274 | { |
||
| 275 | return $this->analyzePnrReply($response); |
||
| 276 | } |
||
| 277 | |||
| 278 | /** |
||
| 279 | * @param SendResult $response PNR_AddMultiElements result |
||
| 280 | * @return Result |
||
| 281 | */ |
||
| 282 | protected function analyzePnrAddMultiElementsResponse($response) |
||
| 283 | { |
||
| 284 | return $this->analyzePnrReply($response); |
||
| 285 | } |
||
| 286 | |||
| 287 | /** |
||
| 288 | * @param SendResult $response PNR_Cancel result |
||
| 289 | * @return Result |
||
| 290 | */ |
||
| 291 | protected function analyzePnrCancelResponse($response) |
||
| 292 | { |
||
| 293 | return $this->analyzePnrReply($response); |
||
| 294 | } |
||
| 295 | |||
| 296 | /** |
||
| 297 | * @param SendResult $response Pnr_RetrieveAndDisplay response |
||
| 298 | * @return Result |
||
| 299 | * @throws Exception |
||
| 300 | */ |
||
| 301 | protected function analyzePnrRetrieveAndDisplayResponse($response) |
||
| 302 | { |
||
| 303 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 304 | } |
||
| 305 | |||
| 306 | /** |
||
| 307 | * Analysing a PNR_TransferOwnershipReply |
||
| 308 | * |
||
| 309 | * @param SendResult $response PNR_TransferOwnership response |
||
| 310 | * @return Result |
||
| 311 | * @throws Exception |
||
| 312 | */ |
||
| 313 | protected function analyzePNRTransferOwnershipResponse($response) |
||
| 314 | { |
||
| 315 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 316 | } |
||
| 317 | |||
| 318 | /** |
||
| 319 | * Analysing a PNR_DisplayHistoryReply |
||
| 320 | * |
||
| 321 | * @param SendResult $response PNR_DisplayHistoryReply result |
||
| 322 | * @return Result |
||
| 323 | * @throws Exception |
||
| 324 | */ |
||
| 325 | protected function analyzePnrDisplayHistoryResponse($response) |
||
| 326 | { |
||
| 327 | $analyzeResponse = new Result($response); |
||
| 328 | |||
| 329 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 330 | |||
| 331 | $queryAllErrorCodes = "//m:generalErrorGroup//m:errorNumber/m:errorDetails/m:errorCode"; |
||
| 332 | $queryAllErrorMsg = "//m:generalErrorGroup/m:genrealErrorText/m:freeText"; |
||
| 333 | |||
| 334 | $errorCodeNodeList = $domXpath->query($queryAllErrorCodes); |
||
| 335 | |||
| 336 | View Code Duplication | if ($errorCodeNodeList->length > 0) { |
|
| 337 | $analyzeResponse->status = Result::STATUS_ERROR; |
||
| 338 | |||
| 339 | $code = $errorCodeNodeList->item(0)->nodeValue; |
||
| 340 | $errorTextNodeList = $domXpath->query($queryAllErrorMsg); |
||
| 341 | $message = $this->makeMessageFromMessagesNodeList($errorTextNodeList); |
||
| 342 | |||
| 343 | $analyzeResponse->messages[] = new Result\NotOk($code, trim($message)); |
||
| 344 | } |
||
| 345 | |||
| 346 | return $analyzeResponse; |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @param SendResult $response Queue_RemoveItem response |
||
| 351 | * @return Result |
||
| 352 | * @throws Exception |
||
| 353 | */ |
||
| 354 | protected function analyzeQueueRemoveItemResponse($response) |
||
| 355 | { |
||
| 356 | return $this->analyzeGenericQueueResponse($response); |
||
| 357 | } |
||
| 358 | |||
| 359 | /** |
||
| 360 | * @param SendResult $response Queue_MoveItem response |
||
| 361 | * @return Result |
||
| 362 | * @throws Exception |
||
| 363 | */ |
||
| 364 | protected function analyzeQueueMoveItemResponse($response) |
||
| 365 | { |
||
| 366 | return $this->analyzeGenericQueueResponse($response); |
||
| 367 | } |
||
| 368 | |||
| 369 | /** |
||
| 370 | * @param SendResult $response Queue_PlacePNR response |
||
| 371 | * @return Result |
||
| 372 | * @throws Exception |
||
| 373 | */ |
||
| 374 | protected function analyzeQueuePlacePNRResponse($response) |
||
| 375 | { |
||
| 376 | return $this->analyzeGenericQueueResponse($response); |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @param SendResult $response Queue_List result |
||
| 381 | * @return Result |
||
| 382 | * @throws Exception |
||
| 383 | */ |
||
| 384 | protected function analyzeQueueListResponse($response) |
||
| 385 | { |
||
| 386 | return $this->analyzeGenericQueueResponse($response); |
||
| 387 | } |
||
| 388 | |||
| 389 | /** |
||
| 390 | * Analyze a generic Queue response |
||
| 391 | * |
||
| 392 | * @param SendResult $response Queue_*Reply result |
||
| 393 | * @return Result |
||
| 394 | * @throws Exception |
||
| 395 | */ |
||
| 396 | protected function analyzeGenericQueueResponse($response) |
||
| 397 | { |
||
| 398 | $analysisResponse = new Result($response); |
||
| 399 | |||
| 400 | $domDoc = $this->loadDomDocument($response->responseXml); |
||
| 401 | |||
| 402 | $errorCodeNode = $domDoc->getElementsByTagName("errorCode")->item(0); |
||
| 403 | |||
| 404 | if (!is_null($errorCodeNode)) { |
||
| 405 | $analysisResponse->status = Result::STATUS_WARN; |
||
| 406 | |||
| 407 | $errorCode = $errorCodeNode->nodeValue; |
||
| 408 | $errorMessage = $this->getErrorTextFromQueueErrorCode($errorCode); |
||
| 409 | |||
| 410 | $analysisResponse->messages[] = new Result\NotOk($errorCode, $errorMessage); |
||
| 411 | } |
||
| 412 | |||
| 413 | return $analysisResponse; |
||
| 414 | } |
||
| 415 | |||
| 416 | |||
| 417 | /** |
||
| 418 | * @param SendResult $response Fare_PricePNRWithBookingClass result |
||
| 419 | * @return Result |
||
| 420 | * @throws Exception |
||
| 421 | */ |
||
| 422 | View Code Duplication | protected function analyzeFarePricePNRWithBookingClassResponse($response) |
|
| 423 | { |
||
| 424 | $analyzeResponse = new Result($response); |
||
| 425 | |||
| 426 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 427 | |||
| 428 | $queryErrorCode = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode"; |
||
| 429 | $queryErrorCategory = "//m:applicationError//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory"; |
||
| 430 | $queryErrorMsg = "//m:applicationError/m:errorWarningDescription/m:freeText"; |
||
| 431 | |||
| 432 | $errorCodeNodeList = $domXpath->query($queryErrorCode); |
||
| 433 | |||
| 434 | if ($errorCodeNodeList->length > 0) { |
||
| 435 | $analyzeResponse->status = Result::STATUS_ERROR; |
||
| 436 | |||
| 437 | $errorCatNode = $domXpath->query($queryErrorCategory)->item(0); |
||
| 438 | if ($errorCatNode instanceof \DOMNode) { |
||
| 439 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue); |
||
| 440 | } |
||
| 441 | |||
| 442 | $analyzeResponse->messages[] = new Result\NotOk( |
||
| 443 | $errorCodeNodeList->item(0)->nodeValue, |
||
| 444 | $this->makeMessageFromMessagesNodeList( |
||
| 445 | $domXpath->query($queryErrorMsg) |
||
| 446 | ) |
||
| 447 | ); |
||
| 448 | } |
||
| 449 | |||
| 450 | return $analyzeResponse; |
||
| 451 | } |
||
| 452 | |||
| 453 | /** |
||
| 454 | * @param SendResult $response |
||
| 455 | * @return Result |
||
| 456 | */ |
||
| 457 | protected function analyzeFareMasterPricerCalendarResponse($response) |
||
| 458 | { |
||
| 459 | return $this->analyzeFareMasterPricerTravelBoardSearchResponse($response); |
||
| 460 | } |
||
| 461 | |||
| 462 | /** |
||
| 463 | * @param SendResult $response |
||
| 464 | * @return Result |
||
| 465 | */ |
||
| 466 | protected function analyzeFareMasterPricerTravelBoardSearchResponse($response) |
||
| 467 | { |
||
| 468 | $analyzeResponse = new Result($response); |
||
| 469 | |||
| 470 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 471 | |||
| 472 | $queryErrCode = "//m:applicationError//m:applicationErrorDetail/m:error"; |
||
| 473 | $queryErrMsg = "//m:errorMessageText/m:description"; |
||
| 474 | |||
| 475 | $codeNode = $domXpath->query($queryErrCode)->item(0); |
||
| 476 | |||
| 477 | if ($codeNode instanceof \DOMNode) { |
||
| 478 | $analyzeResponse->status = Result::STATUS_ERROR; |
||
| 479 | |||
| 480 | $errMsg = ''; |
||
| 481 | $errMsgNode = $domXpath->query($queryErrMsg)->item(0); |
||
| 482 | if ($errMsgNode instanceof \DOMNode) { |
||
| 483 | $errMsg = $errMsgNode->nodeValue; |
||
| 484 | } |
||
| 485 | |||
| 486 | $analyzeResponse->messages[] = new Result\NotOk( |
||
| 487 | $codeNode->nodeValue, |
||
| 488 | $errMsg |
||
| 489 | ); |
||
| 490 | } |
||
| 491 | |||
| 492 | return $analyzeResponse; |
||
| 493 | } |
||
| 494 | |||
| 495 | /** |
||
| 496 | * @param SendResult $response |
||
| 497 | * @return Result |
||
| 498 | */ |
||
| 499 | protected function analyzeFareConvertCurrencyResponse($response) |
||
| 500 | { |
||
| 501 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @param SendResult $response |
||
| 506 | * @return Result |
||
| 507 | */ |
||
| 508 | protected function analyzeFareCheckRulesResponse($response) |
||
| 509 | { |
||
| 510 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 511 | } |
||
| 512 | |||
| 513 | /** |
||
| 514 | * @param SendResult $response |
||
| 515 | * @return Result |
||
| 516 | */ |
||
| 517 | protected function analyzeFareInformativePricingWithoutPNRResponse($response) |
||
| 518 | { |
||
| 519 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 520 | } |
||
| 521 | |||
| 522 | /** |
||
| 523 | * @param SendResult $response |
||
| 524 | * @return Result |
||
| 525 | */ |
||
| 526 | protected function analyzeFareInformativeBestPricingWithoutPNRResponse($response) |
||
| 527 | { |
||
| 528 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 529 | } |
||
| 530 | |||
| 531 | /** |
||
| 532 | * @param SendResult $response |
||
| 533 | * @return Result |
||
| 534 | */ |
||
| 535 | protected function analyzeDocIssuanceIssueTicketResponse($response) |
||
| 536 | { |
||
| 537 | return $this->analyzeSimpleResponseErrorCodeAndMessageStatusCode($response); |
||
| 538 | } |
||
| 539 | |||
| 540 | /** |
||
| 541 | * @param SendResult $response Ticket_DeleteTST result |
||
| 542 | * @return Result |
||
| 543 | */ |
||
| 544 | protected function analyzeTicketDisplayTSTResponse($response) |
||
| 545 | { |
||
| 546 | return $this->analyzeSimpleResponseErrorCodeAndMessage($response); |
||
| 547 | } |
||
| 548 | |||
| 549 | /** |
||
| 550 | * @param SendResult $response Ticket_DeleteTST result |
||
| 551 | * @return Result |
||
| 552 | */ |
||
| 553 | protected function analyzeTicketDeleteTSTResponse($response) |
||
| 554 | { |
||
| 555 | return $this->analyzeTicketCreateTSTFromPricingResponse($response); |
||
| 556 | } |
||
| 557 | |||
| 558 | /** |
||
| 559 | * @param SendResult $response Ticket_CreateTSTFromPricing result |
||
| 560 | * @return Result |
||
| 561 | */ |
||
| 562 | View Code Duplication | protected function analyzeTicketCreateTSTFromPricingResponse($response) |
|
| 589 | |||
| 590 | /** |
||
| 591 | * @param SendResult $response |
||
| 592 | * @return Result |
||
| 593 | */ |
||
| 594 | protected function analyzeOfferConfirmCarOfferResponse($response) |
||
| 598 | |||
| 599 | /** |
||
| 600 | * @param SendResult $response |
||
| 601 | * @return Result |
||
| 602 | */ |
||
| 603 | protected function analyzeOfferConfirmHotelOfferResponse($response) |
||
| 628 | |||
| 629 | /** |
||
| 630 | * @param SendResult $response |
||
| 631 | * @return Result |
||
| 632 | */ |
||
| 633 | protected function analyzeOfferConfirmAirOfferResponse($response) |
||
| 637 | |||
| 638 | /** |
||
| 639 | * @param SendResult $response |
||
| 640 | * @return Result |
||
| 641 | */ |
||
| 642 | protected function analyzeOfferVerifyOfferResponse($response) |
||
| 646 | |||
| 647 | protected function analyzeMiniRuleGetFromPricingRecResponse($response) |
||
| 648 | { |
||
| 649 | $analyzeResponse = new Result($response); |
||
| 650 | |||
| 651 | $domXpath = $this->makeDomXpath($response->responseXml); |
||
| 652 | |||
| 653 | $statusNode = $domXpath->query('//m:responseDetails/m:statusCode')->item(0); |
||
| 654 | if ($statusNode instanceof \DOMNode) { |
||
| 655 | $code = $statusNode->nodeValue; |
||
| 656 | |||
| 657 | if ($code !== 'O') { |
||
| 658 | $categoryNode = $domXpath->query('//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCategory')->item(0); |
||
| 659 | $analyzeResponse->status = $this->makeStatusFromErrorQualifier($categoryNode->nodeValue); |
||
| 660 | |||
| 661 | $codeNode = $domXpath->query('//m:errorOrWarningCodeDetails/m:errorDetails/m:errorCode')->item(0); |
||
| 662 | $msgNode = $domXpath->query('//m:errorWarningDescription/m:freeText')->item(0); |
||
| 663 | |||
| 664 | if ($codeNode instanceof \DOMNode && $msgNode instanceof \DOMNode) { |
||
| 665 | $analyzeResponse->messages[] = new Result\NotOk( |
||
| 666 | $codeNode->nodeValue, |
||
| 667 | $msgNode->nodeValue |
||
| 668 | ); |
||
| 669 | } |
||
| 670 | } |
||
| 671 | } |
||
| 672 | |||
| 673 | return $analyzeResponse; |
||
| 674 | } |
||
| 675 | |||
| 676 | /** |
||
| 677 | * @param SendResult $response |
||
| 678 | * @return Result |
||
| 679 | */ |
||
| 680 | protected function analyzeInfoEncodeDecodeCityResponse($response) |
||
| 684 | |||
| 685 | /** |
||
| 686 | * @param SendResult $response |
||
| 687 | * @return Result |
||
| 688 | */ |
||
| 689 | protected function analyzePriceXplorerExtremeSearchResponse($response) |
||
| 693 | |||
| 694 | /** |
||
| 695 | * @param SendResult $response |
||
| 696 | * @return Result |
||
| 697 | */ |
||
| 698 | protected function analyzeSalesReportsDisplayQueryReportResponse($response) |
||
| 702 | } |
||
| 703 |
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.