Throw a BadMethodCallException calling get{Title,Content} uninitialized

This is bad state so it should not be a breaking change.
pull/93/head
Jan Tojnar 1 year ago
parent 32267cb7b4
commit 9a0a088bc6
  1. 8
      src/Readability.php

@ -249,6 +249,10 @@ class Readability implements LoggerAwareInterface
*/ */
public function getTitle() 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; return $this->articleTitle;
} }
@ -259,6 +263,10 @@ class Readability implements LoggerAwareInterface
*/ */
public function getContent() 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; return $this->articleContent;
} }

Loading…
Cancel
Save