diff --git a/src/Readability.php b/src/Readability.php index f961b4f..c22c0c4 100755 --- a/src/Readability.php +++ b/src/Readability.php @@ -23,8 +23,8 @@ public function parse(string $content): self $this->content->parse($content); } catch (ParseException $e) { $this->content = null; - error_log('Cannot parse: '.$e->getMessage()); - throw new Exception('Cannot parse: '.$e->getMessage()); + error_log('Cannot parse: ' . $e->getMessage()); + throw new Exception('Cannot parse: ' . $e->getMessage()); } return $this; @@ -110,7 +110,6 @@ public function getContent(): string public function getDirection(): string { $this->checkContent(); - return $this->content->getDirection(); } diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php index dced213..6977add 100644 --- a/tests/ReadabilityTest.php +++ b/tests/ReadabilityTest.php @@ -48,6 +48,12 @@ ->and($images)->toContain('/static/img/bitcoin/privacy.svg'); }); +it('can parse and get the direction', function () { + $html = file_get_contents(__DIR__.'/fixtures/demo.html'); + $direction = Readability::parse($html)->getDirection(); + expect($direction)->toBe('ltr'); +}); + it('can parse and get the content', function () { $html = file_get_contents(__DIR__.'/fixtures/demo.html'); $readability = Readability::parse($html); diff --git a/tests/fixtures/demo.html b/tests/fixtures/demo.html index 4da7584..6063aa8 100644 --- a/tests/fixtures/demo.html +++ b/tests/fixtures/demo.html @@ -119,7 +119,7 @@

October 31, 2008

-

Abstract

+

Abstract

A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution.