Passed
Pull Request — master (#481)
by Artem
05:43 queued 01:41
created

HandlerList::getErrorTextFromQueueErrorCode()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 218
Code Lines 210

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 210
c 1
b 0
f 0
dl 0
loc 218
rs 8
cc 3
nc 4
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Amadeus\Client\ResponseHandler\Ticket;
4
5
use Amadeus\Client\ResponseHandler\StandardResponseHandler;
6
7
/**
8
 * HandlerList
9
 *
10
 * @package Amadeus\Client\ResponseHandler\Queue
11
 * @author Marius Marcu <[email protected]>
12
 */
13
class HandlerList extends \Amadeus\Client\ResponseHandler\Queue\HandlerList
14
{
15
    /**
16
     * Returns the errortext from a Ticket_ProcessETicketReply errorcode
17
     *
18
     * This function is necessary because the core only responds
19
     * with errorcode but does not send an errortext.
20
     *
21
     * The errorcodes for all Queue_*Ticket_ProcessETicketReply messages are the same.
22
     *
23
     * @param string $errorCode
24
     * @return string the errortext for this errorcode.
25
     */
26
    protected function getErrorTextFromQueueErrorCode($errorCode)
27
    {
28
        $recognizedErrors = [
29
            '1' => 'Invalid date',
30
            '107' => 'Invalid Airline Designator/Vendor Supplier',
31
            '109' => 'Invalid Country Code',
32
            '111' => 'Invalid Agent\'s Code',
33
            '112' => 'Requestor Identification Required',
34
            '113' => 'Invalid Period of Operation',
35
            '114' => 'Invalid Flight Number',
36
            '115' => 'Invalid Arrival Date',
37
            '116' => 'Invalid Arrival Time',
38
            '118' => 'System Unable to Process',
39
            '12' => 'Invalid product details qualifier coded',
40
            '120' => 'Invalid Action Code',
41
            '129' => 'No PNR Match Found',
42
            '130' => 'Invalid Origin and Destination Pair',
43
            '134' => 'Advise Times Different from Booked',
44
            '135' => 'Advise Dates Different from Booked',
45
            '136' => 'Advise Class Different from Booked',
46
            '144' => 'Invalid Requestor Identification',
47
            '149' => 'Surname too Long',
48
            '151' => 'Surname Mandatory',
49
            '152' => 'Given Name/Title Mandatory',
50
            '153' => 'Name Mismatch',
51
            '154' => 'Message Function Invalid',
52
            '155' => 'Message Function Not Supported',
53
            '156' => 'Business Function Invalid',
54
            '157' => 'Business Function Not Supported',
55
            '159' => 'Phone Field Required',
56
            '18' => 'Invalid on-time performance indicator',
57
            '19' => 'Invalid type of call at port coded',
58
            '190' => 'Invalid Processing Indicator',
59
            '191' => 'Name Reference Required',
60
            '192' => 'Name Reference Inhibited',
61
            '193' => 'Segment Reference Required',
62
            '194' => 'Segment Reference Inhibited',
63
            '2' => 'Invalid time',
64
            '20' => 'Invalid government action coded',
65
            '21' => 'Invalid facility type coded',
66
            '22' => 'Invalid traffic restriction coded',
67
            '23' => 'Invalid traffic restriction type coded',
68
            '24' => 'Invalid traffic restriction qualifier coded',
69
            '244' => 'Not allowed on marketing flights',
70
            '245' => 'Please request on operating carrier',
71
            '25' => 'Invalid transport stage qualifier coded',
72
            '259' => 'Invalid Combination of Generic Codes',
73
            '260' => 'Invalid Frequent Traveler Number',
74
            '266' => 'Limited Recline Seat has been Reserved',
75
            '267' => 'Name in the Request Does Not Match Name in Reservation',
76
            '268' => 'Need Names, Passenger Name Information Required to Reserve Seats',
77
            '269' => 'Indicates that Additional Data for this Message Reference Number follows',
78
            '288' => 'Unable to Satisfy, Need Confirmed Flight Status',
79
            '289' => 'Unable to Retrieve PNR, Database Error',
80
            '294' => 'Invalid Format',
81
            '295' => 'No Flights Requested',
82
            '3' => 'Invalid transfer sequence',
83
            '301' => 'Application Suspended',
84
            '302' => 'Invalid Length',
85
            '304' => 'System Temporarily Unavailable',
86
            '305' => 'Security/Audit Failure',
87
            '306' => 'Invalid Language Code',
88
            '307' => 'Received from data missing',
89
            '308' => 'Received from data invalid',
90
            '309' => 'Received from data missing or invalid',
91
            '310' => 'Ticket arrangement data missing',
92
            '311' => 'Ticket arrangement data invalid',
93
            '312' => 'Ticket arrangement data missing or invalid',
94
            '320' => 'Invalid segment status',
95
            '321' => 'Duplicate flight segment',
96
            '325' => 'Related system reference error',
97
            '326' => 'Sending system reference error',
98
            '327' => 'Invalid segment data in itinerary',
99
            '328' => 'Invalid aircraft registration',
100
            '329' => 'Invalid hold version',
101
            '330' => 'invalid loading type',
102
            '331' => 'Invalid ULD type',
103
            '332' => 'Invalid serial number',
104
            '333' => 'Invalid contour/height code',
105
            '334' => 'Invalid tare weight',
106
            '335' => 'Unit code unknown',
107
            '336' => 'Invalid category code',
108
            '337' => 'Invalid special load reference',
109
            '338' => 'Invalid weight status',
110
            '347' => 'Incompatible loads',
111
            '348' => 'Invalid flight status',
112
            '349' => 'Invalid application/product identification',
113
            '352' => 'Link to inventory system is unavailable',
114
            '354' => 'Invalid product status',
115
            '356' => 'Query control tables full',
116
            '357' => 'Declined to process interactively-default to backup',
117
            '360' => 'Invalid PNR file address',
118
            '361' => 'PNR is secured',
119
            '362' => 'Unable to display PNR and/or name list',
120
            '363' => 'PNR too long',
121
            '364' => 'Invalid ticket number',
122
            '365' => 'Invalid responding system in-house code',
123
            '366' => 'Name list too long',
124
            '367' => 'No active itinerary',
125
            '368' => 'Not authorized',
126
            '369' => 'No PNR is active, redisplay PNR required',
127
            '370' => 'Simultaneous changes to PNR',
128
            '371' => 'Prior PNR display required',
129
            '375' => 'Requestor not authorized for this function for this PNR',
130
            '381' => 'Record locator required',
131
            '382' => 'PNR status value not equal',
132
            '383' => 'Invalid change to status code',
133
            '384' => 'Multiple Name Matches',
134
            '385' => 'Mutually exclusive optional parameters',
135
            '386' => 'Invalid minimum/maximum connect time specified',
136
            '390' => 'Unable to reformat',
137
            '391' => 'PNR contains non air segments',
138
            '392' => 'Invalid block type/name',
139
            '393' => 'Block sell restricted-request block name change',
140
            '394' => 'Segment not valid for electronic ticketing',
141
            '395' => 'Already ticketed',
142
            '396' => 'Invalid ticket/coupon status',
143
            '397' => 'Maximum ticket limit reached',
144
            '399' => 'Duplicate Name',
145
            '4' => 'Invalid city/airport code',
146
            '400' => 'Duplicate ticket number',
147
            '401' => 'Ticket number not found',
148
            '403' => 'Requested Data Not Sorted',
149
            '408' => 'No More Data Available',
150
            '414' => 'Need Prior Availability Request',
151
            '415' => 'Need Prior Schedule Request',
152
            '416' => 'Need Prior Timetable Request',
153
            '417' => 'Repeat Request Updating in Progress',
154
            '437' => 'Carrier must be in separate PNR',
155
            '438' => 'Request is outside system date range for this carrier within this system',
156
            '440' => 'Void request on already voided or printed coupons',
157
            '441' => 'Invalid Priority Number',
158
            '442' => 'System in control of device is unknown',
159
            '443' => 'Device address is unknown',
160
            '445' => 'Security indicator requires originator ID',
161
            '448' => 'Contact Service Provider directly',
162
            '450' => 'All electronic ticket coupons have been printed',
163
            '451' => 'Only individual seat request allowed at this time',
164
            '457' => 'Unable-Connection Market Unavailable',
165
            '459' => 'Owner Equal to Requestor',
166
            '462' => 'Invalid authorization number',
167
            '463' => 'Authorization number already used',
168
            '466' => 'Form of payment missing or invalid for electronic ticketing',
169
            '472' => 'Account does not allow redemption',
170
            '473' => 'No award inventory available for requested market and date',
171
            '5' => 'Invalid time mode',
172
            '6' => 'Invalid operational suffix',
173
            '7' => 'Invalid period of schedule validity',
174
            '705' => 'Invalid or missing Coupon/Booklet Number',
175
            '706' => 'Invalid Certificate Number',
176
            '708' => 'Incorrect credit card information',
177
            '709' => 'Invalid and/or missing frequent traveler information',
178
            '70D' => 'Display criteria not supported',
179
            '710' => 'Free text qualifier error',
180
            '711' => 'Invalid Fare Calculation Status Code',
181
            '712' => 'Missing and/or invalid monetary information',
182
            '713' => 'Invalid Price Type Qualifier',
183
            '716' => 'Missing and/or invalid reservation control information',
184
            '717' => 'Missing and/or invalid travel agent and/or system identification',
185
            '718' => 'Invalid Document Type',
186
            '721' => 'Too much data',
187
            '723' => 'Invalid category',
188
            '724' => 'Invalid routing',
189
            '725' => 'Domestic itinerary',
190
            '726' => 'Invalid global indicator',
191
            '727' => 'Invalid amount',
192
            '728' => 'Invalid conversion type',
193
            '729' => 'Invalid currency code',
194
            '738' => 'Overflow',
195
            '743' => 'Electronic ticket record purposely not accessable',
196
            '745' => 'Refund (full or partial) not allowed',
197
            '746' => 'Open segment(s) not permitted for first coupon or entire itinerary',
198
            '747' => 'Validity date(s) required for electronic tickets',
199
            '748' => 'Status change denied',
200
            '749' => 'Coupon status not open',
201
            '750' => 'Endorsement restriction',
202
            '754' => 'Electronic ticket outside validity date',
203
            '755' => 'Invalid exchange/coupon media',
204
            '757' => 'Exchange paper to electronic ticket not allowed',
205
            '760' => 'Conjunction ticket numbers are not sequential',
206
            '761' => 'Exchange/Reissue must include all unused coupons',
207
            '762' => 'Invalid tax amount',
208
            '763' => 'Invalid tax code',
209
            '766' => 'Ticket has no residual value',
210
            '767' => 'Historical data not available - unable to process',
211
            '790' => 'Exchange denied - no further exchanges allowed',
212
            '791' => 'Unable to void exchanged/reissued ticket',
213
            '792' => 'Segment not eligible for interline electronic ticket',
214
            '793' => 'Fare/tax amount too long',
215
            '794' => 'Invalid or missing fare calculation',
216
            '795' => 'Invalid, missing or conflicting search criteria',
217
            '796' => 'Partial void of ticket coupons not allowed',
218
            '797' => 'Invalid stopover indicator',
219
            '798' => 'Invalid stopover code usage',
220
            '799' => 'Electronic ticket exists, no match on specified criteria',
221
            '79A' => 'Invalid office identification',
222
            '8' => 'Invalid days of operation',
223
            '9' => 'Invalid frequency rate',
224
            '900' => 'Inactivity Time Out Value Exceeded',
225
            '901' => 'Communications Line Unavailable',
226
            '902' => 'Prior message being processed or already processed',
227
            '911' => 'Unable to process - system error',
228
            '912' => 'Incomplete message - data missing in query',
229
            '913' => 'Item/data not found or data not existing in processing host',
230
            '914' => 'Invalid format/data - data does not match EDIFACT rules',
231
            '915' => 'No action - processing host cannot support function',
232
            '916' => 'EDIFACT version not supported',
233
            '917' => 'EDIFACT message size exceeded',
234
235
        ];
236
237
        $errorMessage = (array_key_exists($errorCode, $recognizedErrors)) ? $recognizedErrors[$errorCode] : '';
238
239
        if ($errorMessage === '') {
240
            $errorMessage = "PROCESS E-TICKET ERROR '" . $errorCode . "' (Error message unavailable)";
241
        }
242
243
        return $errorMessage;
244
    }
245
}
246