From b8f55f55e79fed231acfcb9a8d69c72506b89750 Mon Sep 17 00:00:00 2001 From: Julio Foulquie Date: Mon, 5 Mar 2018 17:52:07 -0300 Subject: [PATCH] Use empty() instead of isset() when looking if the cover is empty. When no cover is found, the value of $cover is '', so it's always set. --- src/Parsers/HtmlParser.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Parsers/HtmlParser.php b/src/Parsers/HtmlParser.php index c8717cf..8d596b9 100644 --- a/src/Parsers/HtmlParser.php +++ b/src/Parsers/HtmlParser.php @@ -141,7 +141,7 @@ protected function parseHtml(LinkInterface $link) try { $parser = new Crawler(); - $parser->addHtmlContent($link->getContent()); + $parser->addHtmlContent($link->getContent()); // Parse all known tags foreach($this->tags as $tag => $selectors) { @@ -158,7 +158,9 @@ protected function parseHtml(LinkInterface $link) } // Default is empty string - if (!isset(${$tag})) ${$tag} = ''; + if (!isset(${$tag})) { + ${$tag} = ''; + } } // Parse all images on this page @@ -178,7 +180,9 @@ protected function parseHtml(LinkInterface $link) $images = array_unique($images); - if (!isset($cover) && count($images)) $cover = $images[0]; + if (empty($cover) && count($images)) { + $cover = $images[0]; + } return compact('cover', 'title', 'description', 'images', 'video', 'videoType'); }