Completed
Push — master ( cd1e29...4e1bb4 )
by Yannick
07:06
created

NOTAM   C

Complexity

Total Complexity 64

Size/Duplication

Total Lines 875
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 875
rs 5
c 0
b 0
f 0
wmc 64
lcom 2
cbo 2

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addNOTAM() 0 10 2
A deleteNOTAM() 0 10 2
B updateNotam() 0 11 6
A downloadNOTAM() 0 10 2
A getAllNOTAM() 0 12 2
A deleteAllNOTAMLocation() 0 9 2
F parse() 0 98 47

How to fix   Complexity   

Complex Class

Complex classes like NOTAM 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 NOTAM, and based on these observations, apply Extract Interface, too.

1
<?php
2
require_once(dirname(__FILE__).'/settings.php');
3
require_once(dirname(__FILE__).'/class.Connection.php');
4
require_once(dirname(__FILE__).'/class.Common.php');
5
6
class NOTAM {
7
	public $db;
8
	private $abbr = array(
9
	                    'A/A' => 'Air-to-air',
10
	                    'A/G' => 'Air-to-ground',
11
	                    'AAL' => 'Above Aerodrome Level',
12
	                    'ABM' => 'Abeam',
13
	                    'ABN' => 'Aerodrome Beacon',
14
	                    'ABT' => 'About',
15
	                    'ABV' => 'Above',
16
	                    'ACC' => 'Area Control',
17
	                    'ACFT' => 'Aircraft',
18
	                    'ACK' => 'Acknowledge',
19
	                    'ACL' => 'Altimeter Check Location',
20
	                    'ACN' => 'Aircraft Classification Number',
21
	                    'ACPT' => 'Accepted',
22
	                    'ACT' => 'Active',
23
	                    'AD' => 'Aerodrome',
24
	                    'ADA' => 'Advisory Area',
25
	                    'ADC' => 'Aerodrome Chart',
26
	                    'ADDN' => 'Additional',
27
	                    'ADJ' => 'Adjacent',
28
	                    'ADR' => 'Advisory Route',
29
	                    'ADS' => 'Automatic Dependent Surveillance',
30
	                    'ADVS' => 'Advisory Service',
31
	                    'ADZ' => 'Advised',
32
	                    'AFIL' => 'Flight Plan Filed In The Air',
33
	                    'AFM' => 'Affirm',
34
	                    'AFT' => 'After',
35
	                    'AGA' => 'Aerodromes, Air Routes and Ground Aids',
36
	                    'AGN' => 'Again',
37
	                    'ALERFA' => 'Alert Phase',
38
	                    'ALRS' => 'Alerting Service',
39
	                    'ALS' => 'Approach Lighting System',
40
	                    'ALT' => 'Altitude',
41
	                    'ALTN' => 'Alternate',
42
	                    'AMA' => 'Area Minimum Altitude',
43
	                    'ANC' => 'Aeronautical Chart',
44
	                    'ANCS' => 'Aeronautical Navigation Chart',
45
	                    'ANS' => 'Answer',
46
	                    'AOC' => 'Aerodrome Obstacle Chart',
47
	                    'AP' => 'Airport',
48
	                    'APCH' => 'Approach',
49
	                    'APDC' => 'Aircraft Parking/docking Chart',
50
	                    'APN' => 'Apron',
51
	                    'APNS' => 'Aprons',
52
	                    'APP' => 'Approach Control',
53
	                    'APR' => 'April',
54
	                    'APRX' => 'Approximately',
55
	                    'APSG' => 'After Passing',
56
	                    'APV' => 'Approved',
57
	                    'ARC' => 'Area Chart',
58
	                    'ARNG' => 'Arrange',
59
	                    'ARO' => 'Air Traffic Services Reporting Office',
60
	                    'ARP' => 'Aerodrome Reference Point',
61
	                    'ARR' => 'Arriving',
62
	                    'ARST' => 'Arresting',
63
	                    'ASC' => 'Ascend To',
64
	                    'ASDA' => 'Accelerate-Stop Distance Available',
65
	                    'ASPEEDG' => 'Airspeed Gain',
66
	                    'ASPEEDL' => 'Airspeed Loss',
67
	                    'ASPH' => 'Asphalt',
68
	                    'ATA' => 'Actual Time of Arrival',
69
	                    'ATD' => 'Actual Time of Departure',
70
	                    'ATFM' => 'Air Traffic Flow Management',
71
	                    'ATM' => 'Air Traffic Management',
72
	                    'ATP' => 'At',
73
	                    'ATTN' => 'Attention',
74
	                    'ATZ' => 'Aerodrome Traffic Zone',
75
	                    'AUG' => 'August',
76
	                    'AUTH' => 'Authorization',
77
	                    'AUW' => 'All Up Weight',
78
	                    'AUX' => 'Auxiliary',
79
	                    'AVBL' => 'Available',
80
	                    'AVG' => 'Average',
81
	                    'AVGAS' => 'Aviation Gasoline',
82
	                    'AWTA' => 'Advise At What Time Able',
83
	                    'AWY' => 'Airway',
84
	                    'AWYS' => 'Airways',
85
	                    'AZM' => 'Azimuth',
86
	                    'BA' => 'Braking Action',
87
	                    'BCN' => 'Beacon',
88
	                    'BCST' => 'Broadcast',
89
	                    'BDRY' => 'Boundary',
90
	                    'BFR' => 'Before',
91
	                    'BLDG' => 'Building',
92
	                    'BLO' => 'Below Clouds',
93
	                    'BLW' => 'Below',
94
	                    'BRF' => 'Short',
95
	                    'BRG' => 'Bearing',
96
	                    'BRKG' => 'Breaking',
97
	                    'BTL' => 'Between Layers',
98
	                    'BTN' => 'Between',
99
	                    'CD' => 'Candela',
100
	                    'CDN' => 'Coordination',
101
	                    'CF' => 'Change Frequency To',
102
	                    'CFM' => 'Confirm',
103
	                    'CGL' => 'Circling Guidance Light(s)',
104
	                    'CH' => 'Channel',
105
	                    'CHG' => 'Changed',
106
	                    'CIT' => 'Near or Over Large Towns',
107
	                    'CIV' => 'Civil',
108
	                    'CK' => 'Check',
109
	                    'CL' => 'Centre Line',
110
	                    'CLBR' => 'Calibration',
111
	                    'CLD' => 'Cloud',
112
	                    'CLG' => 'Calling',
113
	                    'CLIMB-OUT' => 'Climb-out Area',
114
	                    'CLR' => 'Clearance',
115
	                    'CLRD' => 'Cleared',
116
	                    'CLSD' => 'Closed',
117
	                    'CMB' => 'Climb',
118
	                    'CMPL' => 'Complete',
119
	                    'CNL' => 'Cancel',
120
	                    'CNS' => 'Communications, Navigation And Surveillance',
121
	                    'COM' => 'Communications',
122
	                    'CONC' => 'Concrete',
123
	                    'COND' => 'Condition',
124
	                    'CONS' => 'Continuous',
125
	                    'CONST' => 'Construction',
126
	                    'CONT' => 'Continued',
127
	                    'COOR' => 'Coordination',
128
	                    'COORD' => 'Coordinates',
129
	                    'COP' => 'Change-over Point',
130
	                    'COR' => 'Correction',
131
	                    'COT' => 'At The Coast',
132
	                    'COV' => 'Covered',
133
	                    'CPDLC' => 'Controller-pilot Data Link Communications',
134
	                    'CPL' => 'Current Flight Plan',
135
	                    'CRC' => 'Cyclic Redundancy Check',
136
	                    'CRZ' => 'Cruise',
137
	                    'CTAM' => 'Climb To And Maintain',
138
	                    'CTC' => 'Contact',
139
	                    'CTL' => 'Control',
140
	                    'CTN' => 'Caution',
141
	                    'CTR' => 'Control Zone',
142
	                    'CVR' => 'Cockpit Voice Recorder',
143
	                    'CW' => 'Continuous Wave',
144
	                    'CWY' => 'Clearway',
145
	                    'DA' => 'Decision Altitude',
146
	                    'DCKG' => 'Docking',
147
	                    'DCP' => 'Datum Crossing Point',
148
	                    'DCPC' => 'Direct Controller-pilot Communications',
149
	                    'DCT' => 'Direct',
150
	                    'DEC' => 'December',
151
	                    'DEG' => 'Degrees',
152
	                    'DEP' => 'Departing',
153
	                    'DES' => 'Descend',
154
	                    'DEST' => 'Destination',
155
	                    'DETRESFA' => 'Distress Phase',
156
	                    'DEV' => 'Deviating',
157
	                    'DFDR' => 'Digital Flight Data Recorder',
158
	                    'DFTI' => 'Distance From Touchdown Indicator',
159
	                    'DH' => 'Decision Height',
160
	                    'DIP' => 'Diffuse',
161
	                    'DIST' => 'Distance',
162
	                    'DIV' => 'Divert',
163
	                    'DLA' => 'Delay',
164
	                    'DLY' => 'Daily',
165
	                    'DNG' => 'Dangerous',
166
	                    'DOM' => 'Domestic',
167
	                    'DPT' => 'Depth',
168
	                    'DR' => 'Dead Reckoning',
169
	                    'DRG' => 'During',
170
	                    'DTAM' => 'Descend To And Maintain',
171
	                    'DTG' => 'Date-time Group',
172
	                    'DTHR' => 'Displaced Runway Threshold',
173
	                    'DTRT' => 'Deteriorating',
174
	                    'DTW' => 'Dual Tandem Wheels',
175
	                    'DUPE' => 'This Is A Duplicate Message',
176
	                    'DUR' => 'Duration',
177
	                    'DVOR' => 'Doppler VOR',
178
	                    'DW' => 'Dual Wheels',
179
	                    'EAT' => 'Expected Approach Time',
180
	                    'EB' => 'Eastbound',
181
	                    'EDA' => 'Elevation Differential Area',
182
	                    'EET' => 'Estimated Elapsed Time',
183
	                    'EFC' => 'Expect Further Clearance',
184
	                    'ELBA' => 'Emergency Location Beacon',
185
	                    'ELEV' => 'Elevation',
186
	                    'ELR' => 'Extra Long Range',
187
	                    'EM' => 'Emission',
188
	                    'EMERG' => 'Emergency',
189
	                    'END' => 'Stop-end',
190
	                    'ENE' => 'East-north-east',
191
	                    'ENG' => 'Engine',
192
	                    'ENR' => 'En-route',
193
	                    'ENRC' => 'En-route Chart',
194
	                    'EOBT' => 'Estimated Off-block Time',
195
	                    'EQPT' => 'Equipment',
196
	                    'ER' => 'Here',
197
	                    'ESE' => 'East-south-east',
198
	                    'EST' => 'Estimate',
199
	                    'ETA' => 'Estimated Time Of Arrival',
200
	                    'ETD' => 'Estimated Time Of Departure',
201
	                    'ETO' => 'Estimated Time Over Significant Point',
202
	                    'EV' => 'Every',
203
	                    'EXC' => 'Except',
204
	                    'EXER' => 'Exercise',
205
	                    'EXP' => 'Expect',
206
	                    'EXTD' => 'Extend',
207
	                    'FAC' => 'Facilities',
208
	                    'FAF' => 'Final Approach Fix',
209
	                    'FAL' => 'Facilitation of International Airtransport',
210
	                    'FAP' => 'Final Approach Point',
211
	                    'FATO' => 'Final Approach And Take-off Area',
212
	                    'FAX' => 'Fax',
213
	                    'FBL' => 'Light',
214
	                    'FCST' => 'Forecast',
215
	                    'FCT' => 'Friction Coefficient',
216
	                    'FDPS' => 'Flight Data Processing System',
217
	                    'FEB' => 'February',
218
	                    'FLD' => 'Field',
219
	                    'FLG' => 'Flashing',
220
	                    'FLR' => 'Flares',
221
	                    'FLT' => 'Flight',
222
	                    'FLTS' => 'Flights',
223
	                    'FLTCK' => 'Flight Check',
224
	                    'FLUC' => 'Fluctuating',
225
	                    'FLW' => 'Follow(s)',
226
	                    'FLY' => 'Fly',
227
	                    'FM' => 'From',
228
	                    'FMS' => 'Flight Management System',
229
	                    'FMU' => 'Flow Management Unit',
230
	                    'FNA' => 'Final Approach',
231
	                    'FPAP' => 'Flight Path Alignment Point',
232
	                    'FPL' => 'Flight Plan',
233
	                    'FPLS' => 'Flight Plans',
234
	                    'FPM' => 'Feet Per Minute',
235
	                    'FPR' => 'Flight Plan Route',
236
	                    'FR' => 'Fuel Remaining',
237
	                    'FREQ' => 'Frequency',
238
	                    'FRI' => 'Friday',
239
	                    'FRNG' => 'Firing',
240
	                    'FRONT' => 'Front',
241
	                    'FRQ' => 'Frequent',
242
	                    'FSL' => 'Full Stop Landing',
243
	                    'FSS' => 'Flight Service Station',
244
	                    'FST' => 'First',
245
	                    'FTP' => 'Fictitious Threshold Point',
246
	                    'G/A' => 'Ground-to-air',
247
	                    'G/A/G' => 'Ground-to-air and Air-to-ground',
248
	                    'GARP' => 'GBAS Azimuth Reference Point',
249
	                    'GBAS' => 'Ground-based Augmentation System',
250
	                    'GCAJ' => 'Ground Controlled Approach',
251
	                    'GEN' => 'General',
252
	                    'GEO' => 'Geographic or True',
253
	                    'GES' => 'Ground Earth Station',
254
	                    'GLD' => 'Glider',
255
	                    'GMC' => 'Ground Movement Chart',
256
	                    'GND' => 'Ground',
257
	                    'GNDCK' => 'Ground Check',
258
	                    'GP' => 'Glide Path',
259
	                    'GRASS' => 'Grass landing area',
260
	                    'GRVL' => 'Gravel',
261
	                    'GUND' => 'Geoid Undulation',
262
	                    'H24' => '24 Hours',
263
	                    'HAPI' => 'Helicopter Approach Path Indicator',
264
	                    'HBN' => 'Hazard Beacon',
265
	                    'HDG' => 'Heading',
266
	                    'HEL' => 'Helicopter',
267
	                    'HGT' => 'Height',
268
	                    'HJ' => 'Sunrise to Sunset',
269
	                    'HLDG' => 'Holding',
270
	                    'HN' => 'Sunset to Sunrise',
271
	                    'HO' => 'Service Available To Meet Operational Requirements',
272
	                    'HOL' => 'Holiday',
273
	                    'HOSP' => 'Hospital Aircraft',
274
	                    'HOT' => 'Height',
275
	                    'HPA' => 'Hectopascal',
276
	                    'HR' => 'Hours',
277
	                    'HRS' => 'Hours',
278
	                    'HS' => 'Service Available During Hours Of Scheduled Operations',
279
	                    'HURCN' => 'Hurricane',
280
	                    'HVY' => 'Heavy',
281
	                    'HX' => 'No Specific Working Hours',
282
	                    'HYR' => 'Higher',
283
	                    'IAC' => 'Instrument Approach Chart',
284
	                    'IAF' => 'Initial Approach Fix',
285
	                    'IAO' => 'In And Out Of Clouds',
286
	                    'IAP' => 'Instrument Approach Procedure',
287
	                    'IAR' => 'Intersection Of Air Routes',
288
	                    'IBN' => 'Identification Beacon',
289
	                    'ID' => 'Identifier',
290
	                    'IDENT' => 'Identification',
291
	                    'IFF' => 'Identification Friend/Foe',
292
	                    'IGA' => 'International General Aviation',
293
	                    'IM' => 'Inner Marker',
294
	                    'IMPR' => 'Improving',
295
	                    'IMT' => 'Immediately',
296
	                    'INA' => 'Initial Approach',
297
	                    'INBD' => 'Inbound',
298
	                    'INCERFA' => 'Uncertainty Phase',
299
	                    'INFO' => 'Information',
300
	                    'INOP' => 'Inoperative',
301
	                    'INP' => 'If Not Possible',
302
	                    'INPR' => 'In Progress',
303
	                    'INSTL' => 'Installation',
304
	                    'INSTR' => 'Instrument',
305
	                    'INT' => 'Intersection',
306
	                    'INTS' => 'Intersections',
307
	                    'INTL' => 'International',
308
	                    'INTRG' => 'Interrogator',
309
	                    'INTRP' => 'Interruption',
310
	                    'INTSF' => 'Intensifying',
311
	                    'INTST' => 'Intensity',
312
	                    'ISA' => 'International Standard Atmosphere',
313
	                    'JAN' => 'January',
314
	                    'JTST' => 'Jet stream',
315
	                    'JUL' => 'July',
316
	                    'JUN' => 'June',
317
	                    'KMH' => 'Kilometres Per Hour',
318
	                    'KPA' => 'Kilopascal',
319
	                    'KT' => 'Knots',
320
	                    'KW' => 'Kilowatts',
321
	                    'LAN' => 'Inland',
322
	                    'LAT' => 'Latitude',
323
	                    'LDA' => 'Landing Distance Available',
324
	                    'LDAH' => 'Landing Distance Available, Helicopter',
325
	                    'LDG' => 'Landing',
326
	                    'LDI' => 'Landing Direction Indicator',
327
	                    'LEN' => 'Length',
328
	                    'LGT' => 'Lighting',
329
	                    'LGTD' => 'Lighted',
330
	                    'LIH' => 'Light Intensity High',
331
	                    'LIL' => 'Light Intensity Low',
332
	                    'LIM' => 'Light Intensity Medium',
333
	                    'LLZ' => 'Localizer',
334
	                    'LM' => 'Locator, Middle',
335
	                    'LMT' => 'Local Mean Time',
336
	                    'LNG' => 'Long',
337
	                    'LO' => 'Locator, Outer',
338
	                    'LOG' => 'Located',
339
	                    'LONG' => 'Longitude',
340
	                    'LRG' => 'Long Range',
341
	                    'LTD' => 'Limited',
342
	                    'LTP' => 'Landing Threshold Point',
343
	                    'LVE' => 'Leaving',
344
	                    'LVL' => 'Level',
345
	                    'LYR' => 'Layer',
346
	                    'MAA' => 'Maximum Authorized Altitude',
347
	                    'MAG' => 'Magnetic',
348
	                    'MAINT' => 'Maintenance',
349
	                    'MAP' => 'Aeronautical Maps and Charts',
350
	                    'MAPT' => 'Missed Approach Point',
351
	                    'MAR' => 'March',
352
	                    'MAX' => 'Maximum',
353
	                    'MAY' => 'May',
354
	                    'MBST' => 'Microburst',
355
	                    'MCA' => 'Minimum Crossing Altitude',
356
	                    'MCW' => 'Modulated Continuous Wave',
357
	                    'MDA' => 'Minimum Descent Altitude',
358
	                    'MDH' => 'Minimum Descent Height',
359
	                    'MEA' => 'Minimum En-route Altitude',
360
	                    'MEHT' => 'Minimum Eye Height Over Threshold',
361
	                    'MET' => 'Meteorological',
362
	                    'MID' => 'Mid-point',
363
	                    'MIL' => 'Military',
364
	                    'MIN' => 'Minutes',
365
	                    'MKR' => 'Marker Radio Beacon',
366
	                    'MLS' => 'Microwave Landing System',
367
	                    'MM' => 'Middle Marker',
368
	                    'MNM' => 'Minimum',
369
	                    'MNPS' => 'Minimum Navigation Performance Specifications',
370
	                    'MNT' => 'Monitor',
371
	                    'MNTN' => 'Maintain',
372
	                    'MOA' => 'Military Operating Area',
373
	                    'MOC' => 'Minimum Obstacle Clearance',
374
	                    'MOD' => 'Moderate',
375
	                    'MON' => 'Monday',
376
	                    'MOPS' => 'Minimum Operational Performance Standards',
377
	                    'MOV' => 'Movement',
378
	                    'MRA' => 'Minimum Reception Altitude',
379
	                    'MRG' => 'Medium Range',
380
	                    'MRP' => 'ATS/MET Reporting Point',
381
	                    'MS' => 'Minus',
382
	                    'MSA' => 'Minimum Sector Altitude',
383
	                    'MSAW' => 'Minimum Safe Altitude Warning',
384
	                    'MSG' => 'Message',
385
	                    'MSSR' => 'Monopulse Secondary Surveillance Radar',
386
	                    'MT' => 'Mountain',
387
	                    'MTU' => 'Metric Units',
388
	                    'MTW' => 'Mountain Waves',
389
	                    'NASC' => 'National AIS System Centre',
390
	                    'NAT' => 'North Atlantic',
391
	                    'NAV' => 'Navigation',
392
	                    'NB' => 'Northbound',
393
	                    'NBFR' => 'Not Before',
394
	                    'NE' => 'North-east',
395
	                    'NEB' => 'North-eastbound',
396
	                    'NEG' => 'Negative',
397
	                    'NGT' => 'Night',
398
	                    'NIL' => 'None',
399
	                    'NML' => 'Normal',
400
	                    'NNE' => 'North-north-east',
401
	                    'NNW' => 'North-north-west',
402
	                    'NOF' => 'International NOTAM Office',
403
	                    'NOV' => 'November',
404
	                    'NOZ' => 'Normal Operating Zone',
405
	                    'NR' => 'Number',
406
	                    'NRH' => 'No Reply Heard',
407
	                    'NTL' => 'National',
408
	                    'NTZ' => 'No Transgression Zone',
409
	                    'NW' => 'North-west',
410
	                    'NWB' => 'North-westbound',
411
	                    'NXT' => 'Next',
412
	                    'O/R' => 'On Request',
413
	                    'OAC' => 'Oceanic Area Control Centre',
414
	                    'OAS' => 'Obstacle Assessment Surface',
415
	                    'OBS' => 'Observe',
416
	                    'OBST' => 'Obstacle',
417
	                    'OBSTS' => 'Obstacles',
418
	                    'OCA' => 'Oceanic Control Area',
419
	                    'OCH' => 'Obstacle Clearance Height',
420
	                    'OCS' => 'Obstacle Clearance Surface',
421
	                    'OCT' => 'October',
422
	                    'OFZ' => 'Obstacle Free Zone',
423
	                    'OGN' => 'Originate',
424
	                    'OHD' => 'Overhead',
425
	                    'OM' => 'Outer Marker',
426
	                    'OPC' => 'Control Indicated Is Operational Control',
427
	                    'OPMET' => 'Operational Meteorological',
428
	                    'OPN' => 'Open',
429
	                    'OPR' => 'Operate',
430
	                    'OPS' => 'Operations',
431
	                    'ORD' => 'Order',
432
	                    'OSV' => 'Ocean Station Vessel',
433
	                    'OTLK' => 'Outlook',
434
	                    'OTP' => 'On Top',
435
	                    'OTS' => 'Organized Track System',
436
	                    'OUBD' => 'Outbound',
437
	                    'PA' => 'Precision Approach',
438
	                    'PALS' => 'Precision Approach Lighting System',
439
	                    'PANS' => 'Procedures for Air Navigation Services',
440
	                    'PAR' => 'Precision Approach Radar',
441
	                    'PARL' => 'Parallel',
442
	                    'PATC' => 'Precision Approach Terrain Chart',
443
	                    'PAX' => 'Passenger(s)',
444
	                    'PCD' => 'Proceed',
445
	                    'PCL' => 'Pilot-controlled Lighting',
446
	                    'PCN' => 'Pavement Classification Number',
447
	                    'PDC' => 'Pre-departure Clearance',
448
	                    'PDG' => 'Procedure Design Gradient',
449
	                    'PER' => 'Performance',
450
	                    'PERM' => 'Permanent',
451
	                    'PIB' => 'Pre-flight Information Bulletin',
452
	                    'PJE' => 'Parachute Jumping Exercise',
453
	                    'PLA' => 'Practice Low Approach',
454
	                    'PLN' => 'Flight Plan',
455
	                    'PLVL' => 'Present Level',
456
	                    'PN' => 'Prior Notice Required',
457
	                    'PNR' => 'Point Of No Return',
458
	                    'POB' => 'Persons On Board',
459
	                    'POSS' => 'Possible',
460
	                    'PPI' => 'Plan Position Indicator',
461
	                    'PPR' => 'Prior Permission Required',
462
	                    'PPSN' => 'Present Position',
463
	                    'PRI' => 'Primary',
464
	                    'PRKG' => 'Parking',
465
	                    'PROB' => 'Probability',
466
	                    'PROC' => 'Procedure',
467
	                    'PROV' => 'Provisional',
468
	                    'PS' => 'Plus',
469
	                    'PSG' => 'Passing',
470
	                    'PSN' => 'Position',
471
	                    'PSNS' => 'Positions',
472
	                    'PSR' => 'Primary Surveillance Radar',
473
	                    'PSYS' => 'Pressure System(s)',
474
	                    'PTN' => 'Procedure Turn',
475
	                    'PTS' => 'Polar Track Structure',
476
	                    'PWR' => 'Power',
477
	                    'QUAD' => 'Quadrant',
478
	                    'RAC' => 'Rules of The Air and Air Traffic Services',
479
	                    'RAG' => 'Runway Arresting Gear',
480
	                    'RAI' => 'Runway Alignment Indicator',
481
	                    'RASC' => 'Regional AIS System Centre',
482
	                    'RASS' => 'Remote Altimeter Setting Source',
483
	                    'RB' => 'Rescue Boat',
484
	                    'RCA' => 'Reach Cruising Altitude',
485
	                    'RCC' => 'Rescue Coordination Centre',
486
	                    'RCF' => 'Radiocommunication Failure',
487
	                    'RCH' => 'Reaching',
488
	                    'RCL' => 'Runway Centre Line',
489
	                    'RCLL' => 'Runway Centre Line Light(s)',
490
	                    'RCLR' => 'Recleared',
491
	                    'RDH' => 'Reference Datum Height',
492
	                    'RDL' => 'Radial',
493
	                    'RDO' => 'Radio',
494
	                    'RE' => 'Recent',
495
	                    'REC' => 'Receiver',
496
	                    'REDL' => 'Runway Edge Light(s)',
497
	                    'REF' => 'Refer To',
498
	                    'REG' => 'Registration',
499
	                    'RENL' => 'Runway End Light(s)',
500
	                    'REP' => 'Report',
501
	                    'REQ' => 'Requested',
502
	                    'RERTE' => 'Re-route',
503
	                    'RESA' => 'Runway End Safety Area',
504
	                    'RG' => 'Range (lights)',
505
	                    'RHC' => 'Right-hand Circuit',
506
	                    'RIF' => 'Reclearance In Flight',
507
	                    'RITE' => 'Right',
508
	                    'RL' => 'Report Leaving',
509
	                    'RLA' => 'Relay To',
510
	                    'RLCE' => 'Request Level Change En Route',
511
	                    'RLLS' => 'Runway Lead-in Lighting System',
512
	                    'RLNA' => 'Request Level Not Available',
513
	                    'RMAC' => 'Radar Minimum Altitude Chart',
514
	                    'RMK' => 'Remark',
515
	                    'RNG' => 'Radio Range',
516
	                    'RNP' => 'Required Navigation Performance',
517
	                    'ROC' => 'Rate Of Climb',
518
	                    'ROD' => 'Rate Of Descent',
519
	                    'ROFOR' => 'Route Forecast',
520
	                    'RON' => 'Receiving Only',
521
	                    'RPI' => 'Radar Position Indicator',
522
	                    'RPL' => 'Repetitive Flight Plan',
523
	                    'RPLC' => 'Replaced',
524
	                    'RPS' => 'Radar Position Symbol',
525
	                    'RQMNTS' => 'Requirements',
526
	                    'RQP' => 'Request Flight Plan',
527
	                    'RQS' => 'Request Supplementary Flight Plan',
528
	                    'RR' => 'Report Reaching',
529
	                    'RSC' => 'Rescue Sub-centre',
530
	                    'RSCD' => 'Runway Surface Condition',
531
	                    'RSP' => 'Responder Beacon',
532
	                    'RSR' => 'En-route Surveillance Radar',
533
	                    'RTE' => 'Route',
534
	                    'RTES' => 'Routes',
535
	                    'RTF' => 'Radiotelephone',
536
	                    'RTG' => 'Radiotelegraph',
537
	                    'RTHL' => 'Runway Threshold Light(s)',
538
	                    'RTN' => 'Return',
539
	                    'RTODAH' => 'Rejected Take-off Distance Available, Helicopter',
540
	                    'RTS' => 'Return To Service',
541
	                    'RTT' => 'Radioteletypewriter',
542
	                    'RTZL' => 'Runway Touchdown Zone Light(s)',
543
	                    'RUT' => 'Standard Regional Route Transmitting Frequencies',
544
	                    'RV' => 'Rescue Vessel',
545
	                    'RVSM' => 'Reduced Vertical Separation Minimum',
546
	                    'RWY' => 'Runway',
547
	                    'RWYS' => 'Runways',
548
	                    'SALS' => 'Simple Approach Lighting System',
549
	                    'SAN' => 'Sanitary',
550
	                    'SAP' => 'As Soon As Possible',
551
	                    'SAR' => 'Search and Rescue',
552
	                    'SARPS' => 'Standards and Recommended Practices',
553
	                    'SAT' => 'Saturday',
554
	                    'SATCOM' => 'Satellite Communication',
555
	                    'SB' => 'Southbound',
556
	                    'SBAS' => 'Satellite-based Augmentation System',
557
	                    'SDBY' => 'Stand by',
558
	                    'SE' => 'South-east',
559
	                    'SEA' => 'Sea',
560
	                    'SEB' => 'South-eastbound',
561
	                    'SEC' => 'Seconds',
562
	                    'SECN' => 'Section',
563
	                    'SECT' => 'Sector',
564
	                    'SEP' => 'September',
565
	                    'SER' => 'Service',
566
	                    'SEV' => 'Severe',
567
	                    'SFC' => 'Surface',
568
	                    'SGL' => 'Signal',
569
	                    'SID' => 'Standard Instrument Departure',
570
	                    'SIF' => 'Selective Identification Feature',
571
	                    'SIG' => 'Significant',
572
	                    'SIMUL' => 'Simultaneous',
573
	                    'SKED' => 'Schedule',
574
	                    'SLP' => 'Speed Limiting Point',
575
	                    'SLW' => 'Slow',
576
	                    'SMC' => 'Surface Movement Control',
577
	                    'SMR' => 'Surface Movement Radar',
578
	                    'SPL' => 'Supplementary Flight Plan',
579
	                    'SPOC' => 'SAR Point Of Contact',
580
	                    'SPOT' => 'Spot Wind',
581
	                    'SR' => 'Sunrise',
582
	                    'SRA' => 'Surveillance Radar Approach',
583
	                    'SRE' => 'Surveillance Radar Element Of Precision Approach Radar System',
584
	                    'SRG' => 'Short Range',
585
	                    'SRR' => 'Search and Rescue Region',
586
	                    'SRY' => 'Secondary',
587
	                    'SS' => 'Sunset',
588
	                    'SSE' => 'South-south-east',
589
	                    'SSR' => 'Secondary Surveillance Radar',
590
	                    'SST' => 'Supersonic Transport',
591
	                    'SSW' => 'South-south-west',
592
	                    'STA' => 'Straight-in Approach',
593
	                    'STAR' => 'Standard Instrument Arrival',
594
	                    'STD' => 'Standard',
595
	                    'STN' => 'Station',
596
	                    'STNR' => 'Stationary',
597
	                    'STOL' => 'Short Take-off and Landing',
598
	                    'STS' => 'Status',
599
	                    'STWL' => 'Stopway Light(s)',
600
	                    'SUBJ' => 'Subject To',
601
	                    'SUN' => 'Sunday',
602
	                    'SUP' => 'Supplement',
603
	                    'SUPPS' => 'Regional Supplementary Procedures Service Message',
604
	                    'SVCBL' => 'Serviceable',
605
	                    'SW' => 'South-west',
606
	                    'SWB' => 'South-westbound',
607
	                    'SWY' => 'Stopway',
608
	                    'TA' => 'Transition Altitude',
609
	                    'TAA' => 'Terminal Arrival Altitude',
610
	                    'TAF' => 'Aerodrome Forecast',
611
	                    'TAIL' => 'Tail Wind',
612
	                    'TAR' => 'Terminal Area Surveillance Radar',
613
	                    'TAX' => 'Taxi',
614
	                    'TCAC' => 'Tropical Cyclone Advisory Centre',
615
	                    'TDO' => 'Tornado',
616
	                    'TDZ' => 'Touchdown Zone',
617
	                    'TECR' => 'Technical Reason',
618
	                    'TEMPO' => 'Temporarily',
619
	                    'TFC' => 'Traffic',
620
	                    'TGL' => 'Touch-and-go',
621
	                    'TGS' => 'Taxiing Guidance System',
622
	                    'THR' => 'Threshold',
623
	                    'THRU' => 'Through',
624
	                    'THU' => 'Thursday',
625
	                    'TIBA' => 'Traffic Information Broadcast By Aircraft',
626
	                    'TIL' => 'Until',
627
	                    'TIP' => 'Until Past',
628
	                    'TKOF' => 'Take-off',
629
	                    'TL' => 'Till',
630
	                    'TLOF' => 'Touchdown And Lift-off Area',
631
	                    'TMA' => 'Terminal Control Area',
632
	                    'TNA' => 'Turn Altitude',
633
	                    'TNH' => 'Turn Height',
634
	                    'TOC' => 'Top of Climb',
635
	                    'TODA' => 'Take-off Distance Available',
636
	                    'TODAH' => 'Take-off Distance Available, Helicopter',
637
	                    'TORA' => 'Take-off Run Available',
638
	                    'TP' => 'Turning Point',
639
	                    'TR' => 'Track',
640
	                    'TRA' => 'Temporary Reserved Airspace',
641
	                    'TRANS' => 'Transmitter',
642
	                    'TRL' => 'Transition Level',
643
	                    'TUE' => 'Tuesday',
644
	                    'TURB' => 'Turbulence',
645
	                    'TVOR' => 'Terminal VOR',
646
	                    'TWR' => 'Tower',
647
	                    'TWY' => 'Taxiway',
648
	                    'TWYL' => 'Taxiway-link',
649
	                    'TXT' => 'Text',
650
	                    'TYP' => 'Type of Aircraft',
651
	                    'U/S' => 'Unserviceable',
652
	                    'UAB' => 'Until Advised By',
653
	                    'UAC' => 'Upper Area Control Centre',
654
	                    'UAR' => 'Upper Air Route',
655
	                    'UFN' => 'Until Further Notice',
656
	                    'UHDT' => 'Unable Higher Due Traffic',
657
	                    'UIC' => 'Upper Information Centre',
658
	                    'UIR' => 'Upper Flight Information Region',
659
	                    'ULR' => 'Ultra Long Range',
660
	                    'UNA' => 'Unable',
661
	                    'UNAP' => 'Unable To Approve',
662
	                    'UNL' => 'Unlimited',
663
	                    'UNREL' => 'Unreliable',
664
	                    'UTA' => 'Upper Control Area',
665
	                    'VAAC' => 'Volcanic Ash Advisory Centre',
666
	                    'VAC' => 'Visual Approach Chart',
667
	                    'VAL' => 'In Valleys',
668
	                    'VAN' => 'Runway Control Van',
669
	                    'VAR' => 'Visual-aural Radio Range',
670
	                    'VC' => 'Vicinity',
671
	                    'VCY' => 'Vicinity',
672
	                    'VER' => 'Vertical',
673
	                    'VIS' => 'Visibility',
674
	                    'VLR' => 'Very Long Range',
675
	                    'VPA' => 'Vertical Path Angle',
676
	                    'VRB' => 'Variable',
677
	                    'VSA' => 'By Visual Reference To The Ground',
678
	                    'VSP' => 'Vertical Speed',
679
	                    'VTOL' => 'Vertical Take-off And Landing',
680
	                    'WAC' => 'World Aeronautical Chart',
681
	                    'WAFC' => 'World Area Forecast Centre',
682
	                    'WB' => 'Westbound',
683
	                    'WBAR' => 'Wing Bar Lights',
684
	                    'WDI' => 'Wind Direction Indicator',
685
	                    'WDSPR' => 'Widespread',
686
	                    'WED' => 'Wednesday',
687
	                    'WEF' => 'Effective From',
688
	                    'WI' => 'Within',
689
	                    'WID' => 'Width',
690
	                    'WIE' => 'Effective Immediately',
691
	                    'WILCO' => 'Will Comply',
692
	                    'WIND' => 'Wind',
693
	                    'WINTEM' => 'Forecast Upper Wind And Temperature For Aviation',
694
	                    'WIP' => 'Work In Progress',
695
	                    'WKN' => 'Weaken',
696
	                    'WNW' => 'West-north-west',
697
	                    'WO' => 'Without',
698
	                    'WPT' => 'Way-point',
699
	                    'WRNG' => 'Warning',
700
	                    'WSW' => 'West-south-west',
701
	                    'WT' => 'Weight',
702
	                    'WWW' => 'Worldwide Web',
703
	                    'WX' => 'Weather',
704
	                    'XBAR' => 'Crossbar',
705
	                    'XNG' => 'Crossing',
706
	                    'XS' => 'Atmospherics',
707
	                    'YCZ' => 'Yellow Caution Zone',
708
	                    'YR' => 'Your');
709
710
711
	function __construct($dbc = null) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
712
		$Connection = new Connection($dbc);
713
		$this->db = $Connection->db;
714
	}
715
	public function getAllNOTAM() {
716
		$query = "SELECT * FROM notam";
717
		$query_values = array();
718
		try {
719
			$sth = $this->db->prepare($query);
720
			$sth->execute($query_values);
721
		} catch(PDOException $e) {
722
			return "error : ".$e->getMessage();
723
		}
724
		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
725
		return $all;
726
	}
727
728
	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
729
		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
730
		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
731
		try {
732
			$sth = $this->db->prepare($query);
733
			$sth->execute($query_values);
734
		} catch(PDOException $e) {
735
			return "error : ".$e->getMessage();
736
		}
737
	}
738
739
	public function deleteNOTAM($id) {
740
		$query = "DELETE FROM notam WHERE id = :id";
741
		$query_values = array(':id' => $id);
742
		try {
743
			$sth = $this->db->prepare($query);
744
			$sth->execute($query_values);
745
		} catch(PDOException $e) {
746
			return "error : ".$e->getMessage();
747
		}
748
	}
749
	public function deleteAllNOTAMLocation() {
750
		$query = "DELETE FROM notam";
751
		try {
752
			$sth = $this->db->prepare($query);
753
			$sth->execute();
754
		} catch(PDOException $e) {
755
			return "error : ".$e->getMessage();
756
		}
757
	}
758
759
	public function updateNotam() {
760
		global $globalNOTAMAirports;
761
		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
762
			foreach ($globalNOTAMAirports as $airport) {
763
				$data = $this->downloadNOTAM($airport);
764
				if (count($data) > 0) {
765
					$this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
766
				}
767
			}
768
		}
769
	}
770
771
	public function downloadNOTAM($icao) {
772
		date_default_timezone_set("UTC");
773
		$Common = new Common();
774
		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
775
		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
776
		$data = $Common->getData($url);
777
		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
778
		if (isset($matches[1])) return $matches[1];
779
		else return array();
780
	}
781
782
	public function parse($data) {
783
		$Common = new Common();
784
		$result = array();
785
		$result['full_notam'] = $data;
786
		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
787
		$data = preg_split('#(?=([A-Z]\)\s))#',$data);
788
		//print_r($data);
789
		foreach ($data as $line) {
790
			$line = trim($line);
791
			if (preg_match('#Q\) (.*)#',$line,$matches)) {
792
				$line = str_replace(' ','',$line);
793
				if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
794
					//print_r($matches);
795
					$result['fir'] = $matches[1];
796
					$result['code'] = $matches[2];
797
					$rules = str_split($matches[3]);
798
					foreach ($rules as $rule) {
799
						if ($rule == 'I') {
800
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/IFR';
801
							else $result['rules'] = 'IFR';
802
						} elseif ($rule == 'V') {
803
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/VFR';
804
							else $result['rules'] = 'VFR';
805
						} elseif ($rule == 'K') {
806
							if (isset($result['rules'])) $result['rules'] = $result['rules'].'/Checklist';
807
							else $result['rules'] = 'Checklist';
808
						}
809
					}
810
					$attentions = str_split($matches[4]);
811
					foreach ($attentions as $attention) {
812
						if ($attention == 'N') {
813
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Immediate attention';
814
							else $result['rules'] = 'Immediate attention';
815
						} elseif ($attention == 'B') {
816
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Operational significance';
817
							else $result['rules'] = 'Operational significance';
818
						} elseif ($attention == 'O') {
819
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Flight operations';
820
							else $result['rules'] = 'Flight operations';
821
						} elseif ($attention == 'M') {
822
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Misc';
823
							else $result['rules'] = 'Misc';
824
						} elseif ($attention == 'K') {
825
							if (isset($result['attention'])) $result['attention'] = $result['attention'].' / Checklist';
826
							else $result['rules'] = 'Checklist';
827
						}
828
					}
829
					if ($matches[5] == 'A') $result['scope'] = 'Airport warning';
830
					elseif ($matches[5] == 'E') $result['scope'] = 'Enroute warning';
831
					elseif ($matches[5] == 'W') $result['scope'] = 'Navigation warning';
832
					elseif ($matches[5] == 'K') $result['scope'] = 'Checklist';
833
					elseif ($matches[5] == 'AE') $result['scope'] = 'Airport/Enroute warning';
834
					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
835
					$result['lower_limit'] = $matches[6];
836
					$result['upper_limit'] = $matches[7];
837
					$latitude = $Common->convertDec($matches[8],'latitude');
838
					if ($matches[9] == 'S') $latitude = -$latitude;
839
					$longitude = $Common->convertDec($matches[10],'longitude');
840
					if ($matches[11] == 'W') $longitude = -$longitude;
841
					$result['latitude'] = $latitude;
842
					$result['longitude'] = $longitude;
843
					$result['radius'] = intval($matches[12]);
844
				} else echo 'ERROR : '.$line."\n";
845
			}
846
			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
847
				$result['icao'] = $matches[1];
848
			}
849
			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
850
				$result['date_begin'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
851
			}
852
			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
853
				$result['date_finish'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
854
			}
855
			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
856
				$result['date_finish'] = $matches[1].'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
857
				if ($matches[6] == 'EST') $result['estimated'] = true;
858
				else $result['estimated'] = false;
859
				if ($matches[6] == 'PERM') $result['permanent'] = true;
860
				else $result['permanent'] = false;
861
			}
862
			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
863
				$text = explode(' ',$matches[1]);
864
				foreach ($text as $word) {
865
					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$rtext was never initialized. Although not strictly required by PHP, it is generally a good practice to add $rtext = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
866
					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
0 ignored issues
show
Bug introduced by
The variable $rtext does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
867
					else $rtext[] = $word;
868
				}
869
				$result['text'] = implode(' ',$rtext);
870
			} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
0 ignored issues
show
Unused Code introduced by
This elseif statement is empty, and could be removed.

This check looks for the bodies of elseif statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These elseif bodies can be removed. If you have an empty elseif but statements in the else branch, consider inverting the condition.

Loading history...
871
			} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
0 ignored issues
show
Unused Code introduced by
This elseif statement is empty, and could be removed.

This check looks for the bodies of elseif statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These elseif bodies can be removed. If you have an empty elseif but statements in the else branch, consider inverting the condition.

Loading history...
872
			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)$#',$line,$matches)) {
873
				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
874
				if ($matches[1] == 'NOTAMC') $result['type'] = 'cancel';
875
				if ($matches[1] == 'NOTAMC') $result['type'] = 'replace';
876
			}
877
		}
878
		return $result;
879
	}
880
}
881
/*
882
$NOTAM = new NOTAM();
883
//print_r($NOTAM->downloadNOTAM('lfll'));
884
print_r($NOTAM->parse(''));
885
*/
886
?>
1 ignored issue
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...