Use match expressions in some places.

This commit is contained in:
wn_
2024-11-23 19:18:52 +00:00
parent 43e8864ead
commit 9b0baf9b32
9 changed files with 73 additions and 140 deletions

View File

@@ -72,19 +72,15 @@ class FeedParser {
$root = $root_list->item(0);
if ($root) {
switch (mb_strtolower($root->tagName)) {
case "rdf:rdf":
$this->type = $this::FEED_RDF;
break;
case "channel":
$this->type = $this::FEED_RSS;
break;
case "feed":
case "atom:feed":
$this->type = $this::FEED_ATOM;
break;
default:
$this->error ??= "Unknown/unsupported feed type";
$this->type = match (mb_strtolower($root->tagName)) {
'rdf:rdf' => $this::FEED_RDF,
'channel' => $this::FEED_RSS,
'feed', 'atom:feed' => $this::FEED_ATOM,
default => null,
};
if (!$this->type) {
$this->error ??= 'Unknown/unsupported feed type';
return;
}
}