From 89c0ccf43eefa1a2d411dea6e1f6eb7fea8de501 Mon Sep 17 00:00:00 2001 From: KiboOst Date: Sat, 7 Dec 2019 13:44:27 +0100 Subject: [PATCH] better --- phpLinkyAPI.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/phpLinkyAPI.php b/phpLinkyAPI.php index f2c0ec5..3eec9ae 100644 --- a/phpLinkyAPI.php +++ b/phpLinkyAPI.php @@ -22,7 +22,10 @@ class Linky{ $resource_id = 'urlCdcHeure'; $result = $this->getData($resource_id, $startDate, $endDate); - if (!isset($result['graphe']['data'])) return false; + if (!isset($result['graphe']['data'])) { + $this->_data['hours'][$date] = null; + return false; + } //format this correctly: $returnData = array(); @@ -58,7 +61,10 @@ class Linky{ $resource_id = 'urlCdcJour'; $result = $this->getData($resource_id, $startDate, $endDate); - if (!isset($result['graphe']['data'])) return false; + if (!isset($result['graphe']['data'])) { + $this->_data['days'] = null; + return false; + } //format this correctly: $returnData = array(); @@ -85,7 +91,10 @@ class Linky{ $resource_id = 'urlCdcMois'; $result = $this->getData($resource_id, $startDate, $endDate); - if (!isset($result['graphe']['data'])) return false; + if (!isset($result['graphe']['data'])) { + $this->_data['months'] = null; + return false; + } //format this correctly: $fromMonth = DateTime::createFromFormat('d/m/Y', $startDate); @@ -114,7 +123,10 @@ class Linky{ $resource_id = 'urlCdcAn'; $result = $this->getData($resource_id, null, null); - if (!isset($result['graphe']['data'])) return false; + if (!isset($result['graphe']['data'])) { + $this->_data['years'] = null; + return false; + } //format this correctly: $fromYear = new DateTime();