From db218f2ce311fd30f9877c5eb8cbe485b1ffce00 Mon Sep 17 00:00:00 2001 From: vbryan Date: Tue, 14 Jun 2022 13:27:18 +0300 Subject: [PATCH] Add fixes to prevent php7.4 warnings --- src/Hypermedia/Parser.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Hypermedia/Parser.php b/src/Hypermedia/Parser.php index b4f0b5b..54e7f9a 100644 --- a/src/Hypermedia/Parser.php +++ b/src/Hypermedia/Parser.php @@ -58,7 +58,12 @@ public function hasLink(ResponseInterface $response, $id) return false; } - return property_exists($this->getLinks($response), $id) ? true : false; + $links = $this->getLinks($links); + if (empty($links)) { + return false; + } + + return property_exists($links, $id) ? true : false; } /** @@ -127,7 +132,12 @@ public function hasEmbed(ResponseInterface $response, $id) return false; } - return property_exists($this->getEmbeds($response), $id) ? true : false; + $embeds = $this->getEmbeds($response); + if (empty($embeds)) { + return false; + } + + return property_exists($embeds, $id) ? true : false; } /** @@ -215,7 +225,12 @@ public function getCurie(ResponseInterface $response, $name) */ protected function responseHasProperty(ResponseInterface $response, $id) { - return property_exists($this->parseJsonBody($response), $id); + $body = $this->parseJsonBody($response); + if (empty($body)) { + return false; + } + + return property_exists($body, $id); } /**