summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2016-12-21 14:04:54 -0300
committerAndres Rey <[email protected]>2016-12-21 14:04:54 -0300
commitf5fb536ffd0f247c0ee5f633089c15f66fbba481 (patch)
tree255187cd9ab67add901fe5d888fe779388bf218a
parent984ded395de1982a773f9639481552550c5e17ef (diff)
Added safe check when getting the article title.
-rw-r--r--src/HTMLParser.php2
-rw-r--r--test/HTMLParserTest.php1
2 files changed, 1 insertions, 2 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php
index fbf3455..43cf505 100644
--- a/src/HTMLParser.php
+++ b/src/HTMLParser.php
@@ -368,7 +368,7 @@ class HTMLParser
}
$title = $this->dom->getElementsByTagName('title');
- if ($title) {
+ if ($title->length > 0) {
return $title->item(0)->nodeValue;
}
diff --git a/test/HTMLParserTest.php b/test/HTMLParserTest.php
index 6d46a90..1e64fdc 100644
--- a/test/HTMLParserTest.php
+++ b/test/HTMLParserTest.php
@@ -2,7 +2,6 @@
namespace andreskrey\Readability\Test;
-
use andreskrey\Readability\HTMLParser;
class HTMLParserTest extends \PHPUnit_Framework_TestCase