From e59e6f92628c8aeb6eccefb3c3470984e16ff525 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Fri, 21 May 2021 03:09:45 +0200 Subject: [PATCH 1/1] Prevent rainfall detection when provider change rain rank --- Command/WeatherCommand.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Command/WeatherCommand.php b/Command/WeatherCommand.php index 64cadd0..4b3ea40 100644 --- a/Command/WeatherCommand.php +++ b/Command/WeatherCommand.php @@ -265,14 +265,16 @@ class WeatherCommand extends DoctrineCommand { //Get rainrisk $rainrisk = str_replace('%', '', trim($node->div[0]->div[0]->div[1]))/100; - //Label is Rain when we have a rainfall - if (($pluviolabel = trim($node->div[1]->div[0]->div[0]->div[1]->p[1])) == 'Rain') { - //Get rainfall - $rainfall = str_replace(' mm', '', $node->div[1]->div[0]->div[0]->div[1]->p[1]->span[0]); - //Cloud Cover, no rainfall - } else { - //Set rainfall to 0 (mm) - $rainfall = 0; + //Set rainfall to 0 (mm) + $rainfall = 0; + + //Iterate on each entry + foreach($node->div[1]->div[0]->div[0]->div[1]->p as $p) { + //Lookup for rain entry if present + if (trim($p) == 'Rain') { + //Get rainfall + $rainfall = floatval(str_replace(' mm', '', $p->span[0])); + } } //Store data -- 2.41.1