Skip to content

Commit

Permalink
Feed: Add edge conditions.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored Oct 16, 2021
1 parent 704ac4f commit ae6954f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,20 @@ private function downloadRawFeed(string $url): string
if ($haystack === false) {
trigger_error('Feed URL "' . $url . '" is broken.');
}
$haystack = trim((string) $haystack);
if ($haystack === '') {
throw new \RuntimeException('Feed response for URL "' . $url . '" is empty.');
}

return (string) $haystack;
return $haystack;
}


private function writeCache(string $url, string $content, ?string $expiration = null): void
{
if ($content === '') { // ignore empty content
return;
}
$this->cache->save($url, $content, [
Cache::EXPIRATION => $expiration ?? $this->expirationTime,
]);
Expand Down

0 comments on commit ae6954f

Please sign in to comment.