Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
murdercode authored and github-actions[bot] committed Feb 29, 2024
1 parent 6fffd65 commit fea91e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/Readability.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,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;
Expand Down Expand Up @@ -68,8 +68,6 @@ public function getImage(): string

/**
* Return the images of the content
*
* @return array
*/
public function getImages(): array
{
Expand Down Expand Up @@ -108,5 +106,4 @@ private function checkContent(): void
throw new Exception('Content is null. Did you forget to call parse()?');
}
}

}
12 changes: 6 additions & 6 deletions tests/ReadabilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
});

it('can parse and get the title', function () {
$content = file_get_contents(__DIR__ . '/fixtures/demo.html');
$content = file_get_contents(__DIR__.'/fixtures/demo.html');
$title = Readability::parse($content)->getTitle();
expect($title)->toBe('Bitcoin: A Peer-to-Peer Electronic Cash System');
});

it('can parse and get excerpt', function () {
$content = file_get_contents(__DIR__ . '/fixtures/demo.html');
$content = file_get_contents(__DIR__.'/fixtures/demo.html');
$excerpt = Readability::parse($content)->getExcerpt();
expect($excerpt)->toBe('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.');
});

it('can parse and get the author', function () {
$content = file_get_contents(__DIR__ . '/fixtures/demo.html');
$content = file_get_contents(__DIR__.'/fixtures/demo.html');
$author = Readability::parse($content)->getAuthor();
expect($author)->toBe('Satoshi Nakamoto');
});

it('can parse and get the image', function () {
$content = file_get_contents(__DIR__ . '/fixtures/demo.html');
$content = file_get_contents(__DIR__.'/fixtures/demo.html');
$image = Readability::parse($content)->getImage();
expect($image)->toBe('https://www.bitcoin.com/wp-content/uploads/2020/10/bitcoin-whitepaper-featured-image.jpg');
});

it('can parse and get images', function () {
$content = file_get_contents(__DIR__ . '/fixtures/demo.html');
$content = file_get_contents(__DIR__.'/fixtures/demo.html');
$images = Readability::parse($content)->getImages();
expect($images)->toBeArray()->toHaveCount(8);
expect($images)->toContain('https://www.bitcoin.com/wp-content/uploads/2020/10/bitcoin-whitepaper-featured-image.jpg');
Expand All @@ -48,7 +48,7 @@
});

it('can parse and get the content', function () {
$content = file_get_contents(__DIR__ . '/fixtures/demo.html');
$content = file_get_contents(__DIR__.'/fixtures/demo.html');
$readability = Readability::parse($content);
$readability->getContent();
expect($readability)->not->toBeNull();
Expand Down

0 comments on commit fea91e4

Please sign in to comment.