diff --git a/app/Support/Metar.php b/app/Support/Metar.php
index 95146e74..fb9be77a 100644
--- a/app/Support/Metar.php
+++ b/app/Support/Metar.php
@@ -515,7 +515,7 @@ class Metar implements \ArrayAccess
// Delete null values from the TAF report
if ($this->result['taf'] === true) {
foreach ($this->result as $parameter => $value) {
- if (!$value) {
+ if ($value === null) {
unset($this->result[$parameter]);
}
}
@@ -530,7 +530,8 @@ class Metar implements \ArrayAccess
} else {
/* @noinspection NestedPositiveIfStatementsInspection */
if (array_key_exists('cloud_height', $this->result) && $this->result['cloud_height'] !== null) {
- if ($this->result['cloud_height']['ft'] > 3000 && $this->result['visibility']['nmi'] > 5) {
+ if ($this->result['cloud_height']['ft'] > 3000
+ && (empty($this->result['visibility']) || $this->result['visibility']['nmi'] > 5)) {
$this->result['category'] = 'VFR';
} else {
$this->result['category'] = 'IFR';
@@ -868,11 +869,11 @@ class Metar implements \ArrayAccess
$this->set_result_value('cavok', false, true);
// Cloud and visibilty OK or ICAO visibilty greater than 10 km
- if ($found[1] === 'CAVOK' || $found[1] === '9999') {
+ if (strtoupper($found[1]) === 'CAVOK' || $found[1] === '9999') {
$this->set_result_value('visibility', $this->createDistance(10000, 'm'));
$this->set_result_value('visibility_report', 'Greater than 10 km');
/* @noinspection NotOptimalIfConditionsInspection */
- if ($found[1] === 'CAVOK') {
+ if (strtoupper($found[1]) === 'CAVOK') {
$this->set_result_value('cavok', true);
$this->method += 4; // can skip the next 4 methods: visibility_min, runway_vr, present_weather, clouds
}
@@ -1484,6 +1485,8 @@ class Metar implements \ArrayAccess
return false;
}
+ // Ignore trends
+ return true;
// Detects TAF on report
if ($this->part <= 4) {
$this->set_result_value('taf', true);
diff --git a/modules/Awards/Awards/PilotFlightAwards.php b/modules/Awards/Awards/PilotFlightAwards.php
index 528b0e71..a13504d9 100644
--- a/modules/Awards/Awards/PilotFlightAwards.php
+++ b/modules/Awards/Awards/PilotFlightAwards.php
@@ -8,7 +8,7 @@ use App\Contracts\Award;
* Simple example of an awards class, where you can apply an award when a user
* has 100 flights. All award classes need to extend Award and implement the check() method
*
- * See: http://docs.phpvms.net/customizing/awards
+ * See: https://docs.phpvms.net/developers/awards
*/
class PilotFlightAwards extends Award
{
diff --git a/phpunit.xml b/phpunit.xml
index b7b5913c..ba75a0d7 100755
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -34,7 +34,7 @@
-
+
diff --git a/tests/MetarTest.php b/tests/MetarTest.php
index 33363853..611631d8 100644
--- a/tests/MetarTest.php
+++ b/tests/MetarTest.php
@@ -173,6 +173,22 @@ class MetarTest extends TestCase
$this->assertInstanceOf(Metar::class, $airportSvc->getMetar('kjfk'));
}
+ /**
+ * TEMPO and trend causing issue with values being overwritten
+ * https://github.com/nabeelio/phpvms/issues/861
+ */
+ public function testLFRSCall()
+ {
+ $this->mockXmlResponse('aviationweather/lfrs.xml');
+
+ /** @var AirportService $airportSvc */
+ $airportSvc = app(AirportService::class);
+
+ $metar = $airportSvc->getMetar('lfrs');
+ $this->assertInstanceOf(Metar::class, $metar);
+ $this->assertTrue($metar['cavok']);
+ }
+
public function testHttpCallSuccessFullResponse()
{
$this->mockXmlResponse('aviationweather/kphx.xml');
diff --git a/tests/data/aviationweather/lfrs.xml b/tests/data/aviationweather/lfrs.xml
new file mode 100644
index 00000000..6335c594
--- /dev/null
+++ b/tests/data/aviationweather/lfrs.xml
@@ -0,0 +1,32 @@
+
+ 109074758
+
+
+
+
+ 7
+
+
+ LFRS 101630Z AUTO 32007KT 280V340 CAVOK 15/05 Q1027 TEMPO SCT035TCU
+ LFRS
+ 2020-10-10T16:30:00Z
+ 47.17
+ -1.6
+ 15.0
+ 5.0
+ 320
+ 7
+ 6.21
+ 30.324802
+
+ TRUE
+
+
+ VFR
+ SPECI
+ 26.0
+
+
+