From f1bd90ffee94df00a88da60eaffa940646609193 Mon Sep 17 00:00:00 2001
From: zadik <zgelici@gmail.com>
Date: Sun, 4 Aug 2019 23:05:26 +0200
Subject: [PATCH 1/2] fix: Notice: Trying to get property 'status' of
 non-object

---
 src/Services/IPApi.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Services/IPApi.php b/src/Services/IPApi.php
index bb65576..8161e19 100644
--- a/src/Services/IPApi.php
+++ b/src/Services/IPApi.php
@@ -71,7 +71,7 @@ public function locate($ip)
         $json = json_decode($data[0]);
 
         // Verify response status
-        if ($json->status !== 'success') {
+        if ($json && $json->status !== 'success') {
             throw new Exception('Request failed (' . $json->message . ')');
         }
 

From 791b3abcf67d745d325998d178af7447d94a51d7 Mon Sep 17 00:00:00 2001
From: zadik <zgelici@gmail.com>
Date: Mon, 5 Aug 2019 23:18:51 +0200
Subject: [PATCH 2/2] Added multiple tries

---
 src/Services/IPApi.php | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/Services/IPApi.php b/src/Services/IPApi.php
index 8161e19..cd64ca0 100644
--- a/src/Services/IPApi.php
+++ b/src/Services/IPApi.php
@@ -22,6 +22,15 @@ class IPApi extends AbstractService
      */
     protected $continents;
 
+
+    /**
+     * Values to try content.
+     *
+     * @var integer
+     */
+    protected $tries = 3;
+
+
     /**
      * The "booting" method of the service.
      *
@@ -70,8 +79,34 @@ public function locate($ip)
         // Parse body content
         $json = json_decode($data[0]);
 
+
+        # Has data
+        if(!$json) {
+            $this->tries = $this->tries-1; #2(1) 1(2)
+            if($this->tries < 0) {
+
+                # requests fails, give empty values back
+                return $this->hydrate([
+                    'ip' => $ip,
+                    'iso_code' => null,
+                    'country' => null,
+                    'city' => null,
+                    'state' => null,
+                    'state_name' => null,
+                    'postal_code' => null,
+                    'lat' => null,
+                    'lon' => null,
+                    'timezone' => null,
+                    'continent' => $this->getContinent(null)
+                ]);
+            }
+
+            # try same request again
+            return $this->locate($ip);
+        }
+
         // Verify response status
-        if ($json && $json->status !== 'success') {
+        if ($json->status !== 'success') {
             throw new Exception('Request failed (' . $json->message . ')');
         }