From 9a0a088bc6bded8a5b6206c18aee760cb786a9e3 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Fri, 11 Oct 2024 09:47:35 +0200 Subject: [PATCH] Throw a BadMethodCallException calling get{Title,Content} uninitialized This is bad state so it should not be a breaking change. --- src/Readability.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Readability.php b/src/Readability.php index a0bb649..9c1b983 100644 --- a/src/Readability.php +++ b/src/Readability.php @@ -249,6 +249,10 @@ class Readability implements LoggerAwareInterface */ public function getTitle() { + if (null === $this->articleTitle) { + throw new \BadMethodCallException('You need to successfully run Readability::init() before you can get title'); + } + return $this->articleTitle; } @@ -259,6 +263,10 @@ class Readability implements LoggerAwareInterface */ public function getContent() { + if (null === $this->articleContent) { + throw new \BadMethodCallException('You need to successfully run Readability::init() before you can get content'); + } + return $this->articleContent; }