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); } /**