1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-07-30 21:30:14 +02:00

fix(senscritique) (#3750)

This commit is contained in:
Dag
2023-10-13 11:24:22 +02:00
committed by GitHub
parent 49d9dafaec
commit 920d00480d
5 changed files with 28 additions and 35 deletions

View File

@@ -2,6 +2,13 @@
declare(strict_types=1);
/**
* Very basic and naive feed parser that srapes out rss 0.91, 1.0, 2.0 and atom 1.0.
*
* Emit arrays meant to be used inside rss-bridge.
*
* The feed item structure is identical to that of FeedItem
*/
final class FeedParser
{
public function parseFeed(string $xmlString): array
@@ -200,6 +207,8 @@ final class FeedParser
'content' => null,
'timestamp' => null,
'author' => null,
'uid' => null,
'categories' => [],
'enclosures' => [],
];
if (isset($feedItem->link)) {

View File

@@ -31,7 +31,10 @@ abstract class FormatAbstract
$this->lastModified = $lastModified;
}
public function setItems(array $items)
/**
* @param FeedItem[] $items
*/
public function setItems(array $items): void
{
$this->items = $items;
}

View File

@@ -7,7 +7,9 @@ final class UrlException extends \Exception
}
/**
* Intentionally restrictive url parser
* Intentionally restrictive url parser.
*
* Only absolute http/https urls.
*/
final class Url
{
@@ -29,7 +31,7 @@ final class Url
$parts = parse_url($url);
if ($parts === false) {
throw new UrlException(sprintf('Invalid url %s', $url));
throw new UrlException(sprintf('Failed to parse_url(): %s', $url));
}
return (new self())
@@ -38,6 +40,7 @@ final class Url
->withPort($parts['port'] ?? 80)
->withPath($parts['path'] ?? '/')
->withQueryString($parts['query'] ?? null);
// todo: add fragment
}
public static function validate(string $url): bool