diff --git a/app/Support/Metar.php b/app/Support/Metar.php index 7f48043a..2d38be5a 100644 --- a/app/Support/Metar.php +++ b/app/Support/Metar.php @@ -993,7 +993,7 @@ class Metar implements \ArrayAccess $observed['amount'] = $found[2]; } } // Cloud cover observed - elseif (isset($found[5]) && !empty($found[5])) { + elseif (isset($found[5]) && !empty($found[5]) && is_numeric($found[5])) { $observed['height'] = new Altitude($found[5] * 100, 'feet'); // Cloud height diff --git a/tests/MetarTest.php b/tests/MetarTest.php index 00c191f0..df259a35 100644 --- a/tests/MetarTest.php +++ b/tests/MetarTest.php @@ -82,6 +82,14 @@ class MetarTest extends TestCase { $metar = 'EGLL 261250Z AUTO 17014KT 8000 -RA BKN010/// ' .'BKN016/// OVC040/// //////TCU 13/12 Q1008 TEMPO 4000 RA'; + + $parsed = Metar::parse($metar); + + $this->assertCount(4, $parsed['clouds']); + $this->assertEquals(1000, $parsed['clouds'][0]['height']['ft']); + $this->assertEquals(1600, $parsed['clouds'][1]['height']['ft']); + $this->assertEquals(4000, $parsed['clouds'][2]['height']['ft']); + $this->assertNull($parsed['clouds'][3]['height']['ft']); } public function testMetarTrends()