From 9b0baf9b32a7f1c299c4bb2127dc192a7daa1ac9 Mon Sep 17 00:00:00 2001 From: wn_ Date: Sat, 23 Nov 2024 19:18:52 +0000 Subject: Use match expressions in some places. --- classes/FeedParser.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'classes/FeedParser.php') diff --git a/classes/FeedParser.php b/classes/FeedParser.php index 729d77206..105708aa2 100644 --- a/classes/FeedParser.php +++ b/classes/FeedParser.php @@ -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; } } -- cgit v1.2.3-54-g00ecf